Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Can't connect if editor is server

Discussion in 'Connected Games' started by AlphaSilverback, Mar 30, 2017.

  1. AlphaSilverback


    Aug 18, 2016
    I'm having a problem where I can't seem to identify the source of the problem:

    I have this project using UNET and so far it has been working to expectations. Then a week ago, I suddenly couldn't connect to a local server if the editor player runs the server. It works fine when another instance of the build runs the server, but I need the server to be run on the editor sometimes to get the debug messages.

    My router is set up with correct forwarding options and my firewall is set up to allow connections from both editor and build instance.

    I've been reading threads all week to try different solutions. I also tried rolling back to a previous version, but curiously it still doesn't work, which suggests a setting on some independent software..

    Please help.
  2. donnysobonny


    Jan 24, 2013
    Hmm yeah that's a strange one. Based on your testing and rolling back not fixing the issue, you'll definitely need to do a bit more digging here and if you're still stuck filing a bug report might be worth doing if it is an issue with unet's internals.

    A few things to help with your digging:
    • have you tried the 5.6 beta? If it's issues with NAT punch through or maybe issues with the current transport layer, 5.6 will solve the issue (the new transport layer is really nice)
    • what is the ip address that you connect to? If you're connecting locally, you'll want to use rather than your public IP
    • if you're using the LLAPI, monitor everything. Look at the responses of the NetworkTransport.Connect call, and the out error byte, and find cases where things aren't what you expect. Do the same on the other end, monitoring the DisconnectEvent and ConnectEvent messages coming from NetworkTransport.Receve calls.

      If you're using the HLAPI, it's more tricky to debug these areas as most things are handled for you. But if you're making Connect/Send calls yourself, look at the return values of these calls. If you're using custom registered handlers, check for errors in the NetworkMessage argument, and also make sure to set up handlers for the Error event etc.
    • Bear in mind that in your connection config, the disconnect timeout defines how long the system waits before it fails a connection attempt (due to inability to connect to the other side). By default, this value is rather high so you can be waiting some time for a failed connection attempts to notify you that it has failed. So make sure to allow some time to see the connection failing, or lower the disconnect timeout in your connection config settings temporarily.
    • If you are using the LLAPI, what arguments do you provide to AddHost on the server side, and what arguments do you provide to AddHost on the client side?
    • are you using websockets anywhere? The behavior or websocket-able networking is different in the editor to how it is in builds...
    I can't really think of anything else, so hopefully one of these points you in the right direction. It's most likely the case that there is an issue happening that you're not making yourself aware of (by not managing errors/return values etc). So that would be the first thing I'd make sure you are doing.

    If you're still stuck, let us know your test results and we can maybe narrow things down for you slightly.
    AlphaSilverback likes this.
  3. AngelGabriel


    Feb 1, 2016
    I think I've hit the same problem... Setup is:
    Unity 5.6.0. Windows 10 Pro. Ethernet peer-to-peer connection. Using the 100% vanilla Network Manager + Network HUD and following Unity's networking tutorial projects.

    A build of my project can act as a host. The editor can act as a host (or server-only) for localhost (loopback) connections. However, the editor *cannot* act as a host (or server-only) for connections between computers.

    In my case I've never seen this kind of connection work. Maybe its undocumented-but-intentional behavior? If so, it needs to change, since it makes host/server debugging very difficult for VR/AR projects where multiple instances on a single computer is not viable.

    @AlphaSilverback @donnysobonny have either of you found a solution to (or more discussion of) this problem?
  4. Jos-Yule


    Sep 17, 2012
    FYI sometimes Windows changes the security policy of apps behind your back. The Unity editor might not be allowed to receive incoming requests now. We've had this issues several times, and it has been something with Windows security policies.
    Mustafanhoso and ceitel like this.
  5. AntzyP


    Apr 8, 2013
    I was having the same problem. Unity Editor worked as client but not as server. Worked in initial project development but stopped working later on. Turns out its the Windows Firewall changing the settings behind our backs as Jos-Yule said.

    The solution I found was disabling Windows Firewall. If you do not want to put your PC at risk, go to Windows Firewall settings -> Advanced Settings ->Inbound Rules. Find Unity Editor in the list. If it has a red cross in front, right click the entry, and select Properties. Then under General tab, select "Allow the connection" under Actions. Should work while keeping Firewall up.
  6. ted-gamaya


    Apr 16, 2013
    We found that you can't have "Use Network Simulator" turned on (2017.1) for some reason
    prankard likes this.
  7. ceitel


    Jan 3, 2017
    Just had this happen to me, been using Unity/Multiplayer for over a year now and it randomly quit allowing incoming connections to the editor. Solved the problem by going to Inbound Rules of the Windows Defender Firewall and found 2 new "block" rules for Unity 2017.3.1f1 Editor and the Package Manager. Possibly after a Unity update I failed to select "Allow" during the initial firewall query. Hope this helps someone.
  8. prankard


    Mar 24, 2010
    Thanks, using 2018.1 and the 'Use Network Simulator' doesn't appear to like it being built and as a client.
  9. carterdawson


    Jan 18, 2014
    For what it's worth, I had this problem too. I checked firewall settings, and I had the same issue as others reported (blocked UnityEditor). But, when I fixed that, it still didn't resolve the problem. What eventually did was changing the Wifi network that I was connecting to from "public" to "private".

    I haven't chased down exactly why that would have made a difference in this case. The firewall settings seemed to be configured for both public and private networks. However, the pirmary network I do my devlopment on should have been classified as private, but wasn't, so this is a reasonable fix for me.

    I haven't looked into the Use Network Simulator thing. (I'm not sure how to do that anyway). I am using 2018.1.0f2.
  10. Channabasappa


    Jan 29, 2017
    Worked perfectly fine, thank you
  11. unity_odkkvAjtDz84Pg


    Jan 16, 2019
    I am having a similar problem.

    When the editor is the server, my program doesn't work, but when the editor is the client and the build is the server, everything works fine. Two builds running without the editor also works fine.

    I have turned off windows firewall, not using network simulator, have pressed face against keyboard. Can't understand why it doesn't work.

    Please help.

    False alarm! Problem solved.
    When the editor was the host, the client was naming its networked game objects differently than when the editor was the client or when the editor was not involved at all and i just had two builds running.
    Last edited: Feb 5, 2019
  12. sami1592


    Sep 18, 2013
    This fixed my errors. I have attached images for convenience.

    2019-08-13 12_37_14-Windows Defender Firewall.png 2019-08-13 12_37_41-Windows Defender Firewall with Advanced Security.png