Search Unity

Launching game with headless server fails.

Discussion in 'FPS.Sample Game' started by jhenzie, Oct 24, 2018.

  1. jhenzie

    jhenzie

    Joined:
    Oct 23, 2017
    Posts:
    1
    The client repeatedly tries to connect to 127.0.0.1.

    The headless server process has no output.

    If I run the server with headless unchecked it launches fine but my GPU is crushed by the two instances.

    I notice that there is an error looking for a configuration file, is this required to be populated in order to connect to a headless server?

    Any ideas?
     
  2. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    I have the same problem when I follow the Using the Quickstart Launcher instructions.

    However, I was able to get quick start to work by changing the "Use Editor as" field from Unused to Server.
     
    Flurgle likes this.
  3. Flurgle

    Flurgle

    Joined:
    May 16, 2016
    Posts:
    389
    @dichardson can confirm that worked for me, thanks
     
  4. AndreasO

    AndreasO

    Joined:
    Sep 25, 2012
    Posts:
    90
    I also had the same problem.
     
  5. petera_unity

    petera_unity

    Unity Technologies

    Joined:
    May 23, 2016
    Posts:
    41
    I would like to understand this problem better. Could you try a few things:

    1. Press Run in the Project Tools and you should get the game running with just the console (but rendered with graphics). If that works fine just type quit

    2. Now fill in the following in the Arguments field above the Run button: -batchmode -nographics
    This should give you the same thing but now as 'headless' where it just brings up a windows console.

    best,
    - peter
     
  6. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    @petera_unity
    I tried using the Project Tools->Run command and it starts the console but exec failed with (buildpath)/game.cfg not found (no graphics).
    Same thing happens when running the game from "Start", but it fails with user.cfg not found also.
     
    Last edited: Oct 25, 2018
  7. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    Run with no arguments
    upload_2018-10-24_22-56-12.png
     
  8. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    Level_01 is Impressive.
    It's going to take some time to see what all is going on.
     
  9. petera_unity

    petera_unity

    Unity Technologies

    Joined:
    May 23, 2016
    Posts:
    41
    The error about game.cfg is innocent (the game always look for game.cfg when booting -- used to configure final builds to do e.g. opening of menu etc., but we should fix the error spewing).

    Did you try pressing Run after filling in the following arguments in the field above Run like this:

    upload_2018-10-24_20-57-0.png

    That *should* launch the game in headless mode so it will just open up a console that looks like a windows command line window.

    Peter
     
  10. MichealPeters-XW

    MichealPeters-XW

    Joined:
    Jan 29, 2018
    Posts:
    15
    I was having the same problem. When switching editor as server it also worked for me, about to try what petera_unity wanted.
     
  11. MichealPeters-XW

    MichealPeters-XW

    Joined:
    Jan 29, 2018
    Posts:
    15
    I'm having the exact same results as Clyde_Coulter, except I haven't seen a failure yet after hitting run with the Arguments. Just a blank Console window

    upload_2018-10-25_9-0-19.png

    upload_2018-10-25_9-1-23.png
     
  12. petera_unity

    petera_unity

    Unity Technologies

    Joined:
    May 23, 2016
    Posts:
    41
    Ok. This is interesting. A couple of things you could try:

    1. Try checking the "Development Build" flag, then Build game, than run again and see what you get.

    2. If it still does not work, try adding another parameter you have:

    -batchmode -nographics -logfile log.txt

    and then when it is done clieck the big "Open build folder" button and send us the log.txt file you have there.

    3. It is not super easy to attach a debugger as this happens at the first awake in the game. But you could also try and follow the code in Game.cs from around line 292 and sprinkle a few prints in to see where it goes wrong. My money is on something in ConsoleTextWin.Init goes wrong....

    peter
     
  13. MichealPeters-XW

    MichealPeters-XW

    Joined:
    Jan 29, 2018
    Posts:
    15
    After rebuilding as a Development build, when it was run, I got a windows security dialog (asking about firewall exceptions) which, to be honest, I was surprised I didn't get the first time. I was hoping that it was going to be the thing that fixed it all, but no, still, no can't connect. I have two questions, one; as I'm attempting this, am I suppose to be pressing run in the project tools or start, because I get different results for each, granted the ultimate result is that it can't connect is the same, but what else pops up is different. 2nd, what port is the server using, and can I set it? Even though after I've turned off the firewall it still failed, I realize that we're trying to access localhost, but I can't help but wonder if the firewall is still fowling things up.it's still somehow connected, seeing as the result is cannot connect to server.
     
  14. MichealPeters-XW

    MichealPeters-XW

    Joined:
    Jan 29, 2018
    Posts:
    15
    Oh, and I forgot to attach my log from my last attempt, and I guess you can ignore my port question, I see some of it in the log files.
     

    Attached Files:

    • log.txt
      File size:
      11.4 KB
      Views:
      870
  15. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    Yeah, mine looks about the same as @MichealPeters-XW
    My machine is an Intel 6 core with GTX-1080 graphics and Windows 10.
     

    Attached Files:

    • log.txt
      File size:
      10.6 KB
      Views:
      884
  16. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    Here's the log file with some debug output. As can be seen, in ConsoleTextWin there's a problem when System.Console.BufferWidth is 0 and m_CurrentLine.Length is 0

    Code (CSharp):
    1.         System.Console.Write(m_CurrentLine + new string(' ', System.Console.BufferWidth - m_CurrentLine.Length - 1));
    2.  
     

    Attached Files:

    • log.txt
      File size:
      14 KB
      Views:
      868
  17. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    AttachConsole fails, but AllocConsole succeeds....hmmm
     
  18. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    Well, that's weird, I called System.Console.SetBufferSize(132, 1000) and it still reports that the System.Console.BufferWidth == 0
     
  19. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    I clone repo, is loads correctly without errors (with LFS 35+ Gb total folder size), I do all steps in start guide (reimport prefabs\models, open Level00, it opens correctly without error, but after press play I have errors :(
    upload_2018-10-26_12-30-23.png

    And also I can't do "Run" or "Start" because it can't find AutoBuild
    upload_2018-10-26_12-29-2.png
    upload_2018-10-26_12-31-27.png
     
  20. suneke

    suneke

    Unity Technologies

    Joined:
    Feb 1, 2017
    Posts:
    10
    Hi, did you also re-import the goo gun prefabs (description in Readme) ?
     
  21. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    Hi, nope, because I'm on 2018.3.0b6 and Readme says do that, if version older than b6 :)
    upload_2018-10-26_16-27-12.png
     
  22. Battleknucks

    Battleknucks

    Joined:
    Nov 3, 2012
    Posts:
    1
    I was also having the issue of the batchmode game not working, if however I run 1 copy as a server without using batchmode, then everything works as expected. This of course requires the server copy to be running with graphics enabled which some people's machines may not be able to handle, but at least you can play it.
     
  23. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    Reimport now (even though I'm on b6) now I can do "Run" game in editor. But cant' Build or Start, because AutoBuild.exe not exists :(

    And I find some funny bug :)
    If you press and hold "CTRL" after "SPACE" (or after drop from anywhere) you can fly :D:D:D:D

    upload_2018-10-27_11-39-55.png
     
    Last edited: Oct 27, 2018
  24. petera_unity

    petera_unity

    Unity Technologies

    Joined:
    May 23, 2016
    Posts:
    41
    I believe that is expected. The AttachConsole path is taken mainly in case of get a console when in Editor (which you cannot do without changing the code because they you end with a console window you can click X on and take down the editor :) Not useful outside testing of the actual console code).

    So back to tracing this: By "AllocConsole succeeds" you mean that you changed to code and verified that the return value is nonzero, right?

    This is tricky to trace without access to a repro... If someone has the repro and a stomach for pinvoke stuff into Win32, feel free to step forward :)

    -peter
     
  25. petera_unity

    petera_unity

    Unity Technologies

    Joined:
    May 23, 2016
    Posts:
    41
    The fly-mode is actually a debug feature of the preview game mode (when you hit play in editor). Useful to get around the level freely. Should hopefully be disabled in normal (networked) gamemode.

    When you write "Cant build" I assume you mean that you get some error when you click on "Build Game"? Because that is what should produce the AutoBuild.exe. So until you get a successfull "Build Game" you cannot use neither Run nor Start.

    peter
     
  26. Mominon

    Mominon

    Joined:
    Feb 1, 2016
    Posts:
    1
    Hello,

    I've managed to track down the issue regarding the empty console, while running in headless mode.

    The
    RunBuild()
    from the Editor spawns the AutoBuild process with
    UseShellExecute
    set to
    false
    , which messes with the Console's buffer.

    Here is the pull request: https://github.com/Unity-Technologies/FPSSample/pull/17

    Have fun!
     
  27. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    No I only use Project Tools window, I say about green Start and red Build All buttons
     
  28. Legolas-Muradin

    Legolas-Muradin

    Joined:
    Nov 20, 2014
    Posts:
    2
    It worked. Thank you.
     
    Mominon likes this.
  29. tonifang

    tonifang

    Joined:
    Oct 11, 2016
    Posts:
    3
    It works! Thanks!
     
    Mominon likes this.