Search Unity

Networking using WebSocketSharp-Port is open but it doesn't connect

Discussion in 'Connected Games' started by TheHeftyCoder, Sep 7, 2019.

  1. TheHeftyCoder

    TheHeftyCoder

    Joined:
    Oct 29, 2016
    Posts:
    5
    Hello, I've been using an implementation of server and client sockets based on WebSocketSharp. That's all I really need for the game I'm making. [ The implementation comes as part of this MasterServer Framework Asset: https://assetstore.unity.com/packages/tools/network/master-server-framework-71391 , or its GitHub equivalent, since it went open source. ]

    I've already built a server and client on my project around 1 and a half years ago, on Unity 2017. It worked after I lifted some security (firewalls) and opened my ports. I re-implemented this in Unity 2019. It works locally (I can connect to a server existing in the same scene as a client, using 127.0.0.1), but my team can't connect to the game remotely from their PCs, even though I have opened the ports (and provided them with my public IP). The strangest thing is that sites such as https://portchecker.co/check that let you check your ports find that my specified port when the server is running is open. I'd really appreciate any insight on the situation. Definite changes are that I'm currently in Unity 2019 and that I'm using the Unity Hub.

    The best I could narrow down to is this. There seems to be an issue based on Unity Versions. If I'm using Unity 2019 (any) as Server and Client, connection won't be established. If I'm using Unity 2017 as Server and 2019 as Client, it doesn't connect. If I'm using Unity 2019 as Server and 2017 as Client, it connects. If I'm using Unity 2017 as both Server and Client, it connects. Both 2019 an 2017 connect locally.

    Thanks a lot in advance!
     
    Last edited: Sep 7, 2019
  2. MrsPiggy

    MrsPiggy

    Joined:
    Jun 13, 2018
    Posts:
    93
    Your team connecting remotely means over the internet right?
    Have you tried connecting a client inside your private network but running on a different machine/IP than the server?
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    6,340
    If it works using 127.0.0.1 but does not remotely, you are either binding to the wrong NIC/IP on the server (if your server asset supports that), or the issue is network or firewall related. Take as many variables out of the situation as possible and step through the problem.

    1) Connect from the same computer using the NIC IP address instead of the loopback address
    - If fails the problem is either with your server application or software firewall related
    2) Connect from a computer on the same switch
    3) Continue moving further and further out until you find the specific issue
     
    MrsPiggy likes this.
  4. doctorpangloss

    doctorpangloss

    Joined:
    Feb 20, 2013
    Posts:
    216
  5. TheHeftyCoder

    TheHeftyCoder

    Joined:
    Oct 29, 2016
    Posts:
    5
    Thanks for all your answers! I've been checking with the source code and it seems the developer at some point changed the client socket to ping (using the Ping API from Unity) the server before connecting. Upon receiving the ping, the client would then connect. Well, you may have already guessed but forwarding a port does not mean you have enabled pinging for your server.
     
  6. TheHeftyCoder

    TheHeftyCoder

    Joined:
    Oct 29, 2016
    Posts:
    5
    Thank you for this! I'll check it out since it seems it can help a lot!