Search Unity

How to host a dedicated server UNET

Discussion in 'UNet' started by IAMBATMAN, Aug 27, 2016.

  1. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    I'm not sure dedicated is the right I want a server that isn't a host and a client at the same time but just a host.

    I'll then have some sort of browser list that list all these dedicated servers that can be hosted by anyone with an open port.

    So can I have a step by step guide on how to host a dedicated server for my Standalone Unity UNet game?
     
  2. DRRosen3

    DRRosen3

    Joined:
    Jan 30, 2014
    Posts:
    683
    Sounds like you want a headless server. Many threads and posts about that around here. Just Google "unity unet headless server".
     
  3. darthbator

    darthbator

    Joined:
    Jan 21, 2012
    Posts:
    169
    I'm actually starting to work on the exact same thing right now! Building the headless server is fairly trivial. If you're hosting on a cloud service (AWS/OpenStack stuff). Just build an x86_64 build of your game for linux and check the "Headless" build option. Apparently this automatically puts unity into "bachmode" with the "nographics" flag. Make sure to include the data directory it generates along with the player binary. Then just upload it and run it from the shell like any other application.

    I am running into some issues debugging the deployed server. It looks like the server is in a good state to accept clients (OnStartServer has fired and the udp port is open on the host) but I can't seem to get a connection going. I don't even see connection attempts fire in OnServerConnect and nothing is coming up in OnServerError. I'm sort of assuming this is due to not having the correct UDP ports open on my local NAT? I'm sort of surprised Unity doesn't attempt to make a UPNP request when then client fires up in the player if that's the case...

    Huh... That doesn't appear to be the issue. I just opened every UDP port on my local NAT for the client computer and I still don't even see an attempt to connect on my server... I also don't get any console errors on the client it just reloads the offline scene (after what I am assuming is a network timeout).
     
    Last edited: Aug 29, 2016
  4. darthbator

    darthbator

    Joined:
    Jan 21, 2012
    Posts:
    169
    Make sure to remember that "security groups" exist to control access to upstream network devices on most providers. I was ripping my hair out trying to figure out where the network was knocking me down before I remembered that...

    It's really as simple as making the headless linux build, assuring port access, and running the binary.
     
  5. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    What if, I wanted to host it on my home computer that's running windows?
     
  6. Acid-NN-9

    Acid-NN-9

    Joined:
    Apr 29, 2015
    Posts:
    10
    Man, you need to build for windows at the same method just as darthbator said. Darthbator put you in a real scenario.

    This question makes me another, ¿can i build a network architecture with native Unity Unet without their payment services?