Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Run Headless build in Ubuntu Server

Discussion in 'Multiplayer' started by oliran, Oct 17, 2016.

  1. oliran

    oliran

    Joined:
    Sep 29, 2015
    Posts:
    48
    I built a headless build of my game and uploaded to dedicated server running Ubuntu Server 16.04. I am trying to run the game on server to host MP games.

    However when I run the game, I get the following:


    I don't know if it's listening for connections or what it is doing. I also don't know where the log files are. When I try to connect through another pc, it fails. I'm not even sure how to tell it which ports to listen to. I have a Network Controller object with Network Port set to 7777, but I'm not sure if that's all I need to do.

    Any help please?
     
  2. jaybdemented

    jaybdemented

    Joined:
    Sep 2, 2013
    Posts:
    112
    If you upoaded it to a host provider then you may need to get which port to use from them. Sadly im still learning myself so thats all i got
     
  3. oliran

    oliran

    Joined:
    Sep 29, 2015
    Posts:
    48
    Thanks! Since I posted I found out:

    1) netstat -atun will tell me which ports are being listened to.
    2) adding -logfile log.txt keeps a log file.

    netstat shows me that the game isn't listening to any ports, so I must have done something wrong in the code... I'm going back and checking, but I haven't been able to find any tutorials online that clearly show how to do this. I'll keep this updated as I find out more so hopefully through my torture I can at least help someone.
     
  4. oliran

    oliran

    Joined:
    Sep 29, 2015
    Posts:
    48
    Ok I figured it out, and I used this free asset to do so: https://www.assetstore.unity3d.com/en/#!/content/61069

    Once I carefully analyzed that, it all started making sense. Also, I start the game on the server using this command:

    ./server.x86_64 -batchmode -nographics -logfile log.txt

    Then to save myself from building two different versions, I check for headless mode using code here: https://noobtuts.com/unity/detect-headless-mode (Alternatively I could have used #define)

    Hopefully this helps someone!