Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Networking: Headless Game Instances

Discussion in 'Multiplayer' started by DocSWAB, Oct 22, 2007.

  1. DocSWAB

    DocSWAB

    Joined:
    Aug 28, 2006
    Posts:
    615
    I know new tutorials and expanded documentation are on the way, but perhaps UT can offer a sneak peek/pre-release of the info about running a headless game instance to serve as an authoritative server for multiplayer networked games.

    In particular, I've lost track of what platforms the headless versions can run on -- OSX only or Windows as well?

    And is running it headless as simple as launching the game build from the Terminal?

    We are trying to get our multiplayer hardware requirements for WolfQuest straightened out and need to know if we have to colocate a Mac to act as a server or if we can use a commercial WIndows Web host.

    Thanks,
    Steve
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    I don't know how UT has planned to offer headless servers, but it's easy enough to simply disable all your cameras, make sure "run in background" is checked, and that can be run via Terminal. Whatever UT's solution is, I'm sure that if nothing else you can test your server using this method until theirs is released.

    (Probably.)
     
  3. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    There are 2 kinds of servers from what I remember;
    The 1st is where you run a normal or headless version of unity as a Master Peer. The headless version is just like a normal client but with no visual output and runs on Mac. I think I remember David saying it will be available on Windows soon (or it already is, best to check).

    The 2nd type is the Master Server, which facilitates clients in finding other Master Peers (which could be headless or not) and NAT punching etc. This server runs on Mac, Linux and Windows (at least the source projects are available for the last 2). Unity Tech. also hosts a public one that you can use.

    If you have a small number of players per game, you could just let one of the players act as the Master Peer for that game and the players Client Peers can connect to it. If your clients are behind firewalls, which is likely, you'll need the Master Server to negotiate NAT traversal for internal IP's - The Master Server holds a list of all registered Master Peer servers and helps client peers connect.

    Hope this explanation is not too ambiguous. The Networking doco is pretty good - if you haven't already, I'd suggest reading it top to bottom.

    Cheers
    Shaun
     
  4. DocSWAB

    DocSWAB

    Joined:
    Aug 28, 2006
    Posts:
    615
    Thanks Shaun,
    I did read the docs and heard the talk at Unify!, so I think I'm reasonbly clear on the Master Server and Master Peer. So it is a question of whether you can launch a headless version of a game instance in Windows. (Beside's Ray's suggestion to build a "regular" Windows build with no cameras.

    Because we want kids who are not necessarily hard core gamers to play WolfQuest, and because we want to minimize lag, etc. we are assuming we will host the Master Peer game instances ourselves. One thing I'm trying to ascertain is whether we can do that on a commodity host like GoDaddy, or if we have to colocate our own physical server in a datacenter, and if so, what it can be running on. (Since an XServe would be on the expensive side).

    Thanks,
    Steve
     
  5. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    I've built a "head-still-on" Master Peer in windows before and it worked OK - it was with the Unity Alpha, so I can't vouch that things haven't changed.

    I really don't know if headless can run on windows yet.

    Are you sure thats the right solution to put a headless client out in the wild? For sure its more reliable to connect to (no NAT traversal required) - but wouldnt you be limiting your players all to the same game instance?

    I was assuming you would have a large number of small (8 or so players) sessions running and control that session list with the Master Server - but maybe im off track :)
     
  6. DocSWAB

    DocSWAB

    Joined:
    Aug 28, 2006
    Posts:
    615
    I'm getting out of my depth here, but was assuming from what I understood that for every group of players, we would have to launch a Master Peer instance (headless or not) on the server box we control, and then use the Master Server (ours or UT's) to let players connect. My thought at running the Master Peer ourselves was that we could reduce lag and be more confident about the bandwidth from the Player Peers to the Master Peer. Working with kids we also have privacy issues that controlling the Master Peer might help with.

    Is that what you're describing?
     
  7. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    I think you're over-concerned about using a peer-to-peer methodology. With the Master Server facilitating NAT punch-through and connections, there's little reason to worry about it - it's effectively the same techinque used by Battle.net, and that of course has been a runaway success. I haven't looked into it, but the Master Server might even run on a web host like GoDaddy (which I can guarantee you, a full-on game server, even headless, definitely will not)
     
  8. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    The Master Server can run on Linux - but you'll need co-lo or dedicated hosting, as its a service that needs to be installed. Luckily thats not very expensive these days.

    To get an idea, the Master Server is really just a database that lets Master Peers register with it. They tell the Master Server their External and Internal IP and the name of their session + password etc.

    When Client Peers query the Master Server, it tells them which sessions are available for them to join and, most importantly, it assists with connecting them with the Master Peer (who is 'hosting' the session) that is behind a NAT router.

    Here is a bit of background on the Master Server from Rakkarsoft, they make RakNet - which is what Unity uses for networking:
    http://www.rakkarsoft.com/raknet/manual/lightweightdatabase.html

    Generally in most networked P2P games one of the clients acts as the controlling (or master) peer for the other clients. This works fine for small numbers of players as the Master Peer usually doesn't have to deal with too much traffic.
    Anything that connects a large number of people at the same time (like second life etc) needs a much stronger server environment - and is hugely more complex to architect.

    I'm still not sure how many simultaneous players you have per game, but that should determine how you proceed. I don't think headless is really the main issue at the moment.

    Anyway - good luck :)
    shaun
     
  9. dingosmoov

    dingosmoov

    Joined:
    Jul 12, 2005
    Posts:
    559
    thanks shaun! Can someone do a drawing of this? I know that may be rudimentary, but it would really help me in understanding the networking. A simplified schematic.... Please:)
     
  10. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    I think someone at Unity should do it - but if they don't, then I'll have a shot when I have a spare moment.
     
  11. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    There was a great presentation at Unite by Lars on Networking, and UT has promised to put up videos of the sessions. It might be good to wait for that!

    Cheers,
    -Jon
     
  12. dingosmoov

    dingosmoov

    Joined:
    Jul 12, 2005
    Posts:
    559
    Any more on this?
     
  13. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    Waiting for Unite videos...
    I've just finished a 200 slide PowerPoint presentation - not in the mood for more diagrams just yet ;)
     
  14. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Is there any solid information anywhere about this headless mode for Unity 2.0?

    All I've found so far are a few threads like this one, some "rumors" about a headless mode in Unity, which may or may not be available in Windows (it probably is for Mac OS but that doesn't help me because I don't have a hosted Mac OS server and wouldn't want to rent one).

    Right now, what I need to do is start up an instance of the game on my hosted Windows server, which opens a huge black window which simply doesn't look cool ;-) nor does it serve any purpose. I'm not sure why it is this huge, either (have set Default Screen Width / Height to 200, which should be reasonably small, but it comes up more like about 1000x1000).

    Unfortunately, it does not only "not look cool" but also messes up the Remote Desktop Client on Mac OS. When I accidentally log in with that RDC, I basically have to open the Windows RDC, shut down the server from there to even be able to close the Mac RDC, and then restart it from the Windows RDC. My "dark Unity Window" is the only thing that does this for the Mac OS RDC (I don't have a lot of applications on that server though, so that does not say a lot, and the Mac OS RDC for Windows is still beta, too).

    Any news on this "headless" mode? Any documentation? I've tried "-headless" and "/headless" when starting the game server instance from the command line, but that had no effect (on a Windows build) ;-)

    Jashan

    PS: Btw, even though I don't think I like godaddy, you can definitely rent a dedicated Windows server there, which would definitely be able to run a game server (and there's other options for dedicated servers aside of godaddy... ThePlanet seems to be quite okay, but I'm using 11 which AFAIK has a very good reputation in Germany, at least for hosted servers, and a very bad reputation in the US ;-) )
     
  15. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    I just posted a question about this on the Unity Beta list... and got no response :?

    I don't believe a headless version for Windows is available. Larus is the guy in the know for all things networking - it's probably still in the works I guess. It would be cool to create a windows service that can accept instantiate a headless build on demand - hmm this would be kind of like a reflection server... and I know that is being worked on (although they would likely be different apps), and will solve a LOT of NAT problems (like hairpin punchthru and stacked NAT etc)... sorry, getting OT... :D

    Cheers
    Shaun
     
  16. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Headless mode is currently not implemented on Windows.
     
  17. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Hi Aras,

    thanks for the information - that clears it up...

    Jashan
     
  18. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    oh oh... bad news :-(

    Has anyone ever tried running a Unity game server as a Windows service? I was thinking, as even VMWare runs as a service, that shouldn't be a problem - but my Unity game server immediately crashes, when I try to have it run as a service by Firedaemon... Not sure if I'm doing anything wrong here, but maybe a headless mode is more needed than I thought... I can easily run the game server by clicking on its icon, or from the console - but there seems to be something to it when running it inside of Firedaemon that makes it choke.

    I've attached the crash-log in my bug report 17492.

    Jashan