Search Unity

Server Disconnects Player for 'Timeout' when clearly the player is sending messages

Discussion in 'Multiplayer' started by F3RULLO14, Jun 26, 2017.

  1. F3RULLO14

    F3RULLO14

    Joined:
    Oct 14, 2013
    Posts:
    57
    Hello, I'm having an issue with Server and Client connections for my game.

    Basically, the player is getting timed out by the server, but then the server doesn't seem to appear on the server list provided by Unity MM? The player and server are sending proper packets back and forth. I can drop and pick up items perfectly fine.

    Example:
    I built my server version of the game and ran it on a VPN with proper ports open and etc. It was successful and opened up properly. I ran my client in the editor, connected to the server, then got timed out after a minute or so. I ran my client out of the editor as a built .exe, got the same result. I also noticed that whenever I try to search for the server on the list, it doesn't come up after I get disconnected.

    If anyone has an idea to why this is happening, I'm all ears. Maybe something to do with pinging to the MM services? I don't know.
     
  2. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Defenently nothing to do with the matchmaker. Matchmaker does nothing after pairing process. However, I think you might be using Relay servers and you are using too much bandwidth.
     
  3. F3RULLO14

    F3RULLO14

    Joined:
    Oct 14, 2013
    Posts:
    57
    How can I monitor the bandwidth? Or should I just go through my code and minimize it? I don't spam updates or Rpc/Cmd methods.
     
  4. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Personally, i don't know. But I would try to run without the relay from the VPS and then see if you have the same issue
     
  5. F3RULLO14

    F3RULLO14

    Joined:
    Oct 14, 2013
    Posts:
    57
    Like a direct connection? Skip the MM Service kinda deal?
     
  6. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    MM is no issue. MM is just a list of servers that the client can request. The Relay is the problem here. But a direct connection should work to avoid Relay.
     
  7. F3RULLO14

    F3RULLO14

    Joined:
    Oct 14, 2013
    Posts:
    57
    Alright, Im running some pings tests, direct connection and so on. Ill let you know how it goes.
     
  8. F3RULLO14

    F3RULLO14

    Joined:
    Oct 14, 2013
    Posts:
    57
    @TwoTen Okay so I got some interesting information from my tests.

    Starting the server with MM CreateMatch:
    - Client connects fine via MatchList but is disconnected after 1-2mins.
    - Client can NOT direct connect using StartClient with the ip and port given.

    Starting the server with StartServer:
    - Client direct connects (StartClient) and holds connections perfectly.

    This was all tested with the server being on my VPS I host from OVH. Its a server box with Windows Server 2012. I have the proper ports open too. Not sure if this info is useful or not but doesn't hurt to provide.

    So my problem lies somewhere with the MM services. Any ideas why it would be happening?
     
  9. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Uhm. A matchmaker is simply a list of servers. Nothing to do with the connection. And if you can't direct connect. Then something is wrong.

    This is what I believe:
    I THINK the matchmaker and relay work together. So if you use the Matchmaker you also use the relay. And since you cant direct connect this means that it probably works because of the relay.
    You also DC after 1-2 minutes wich is the time for the "Bandwidth grace period".

    You need to make sure that the VPS has a public IP and is not sitting behind a NAT.
    If you then use NetworkManager you need to get the singleton and set:
    networkPort
    networkAddress
    Then Call StartClient.

    Please try this.
     
  10. F3RULLO14

    F3RULLO14

    Joined:
    Oct 14, 2013
    Posts:
    57
    I tried that. I couldn't connect to the server when setting the networkAddress and port on the client. It only worked when I started the server via StartServer and not CreateMatch
     
  11. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Yes. That should be correct. But if you start via StartServer. The direct connect. Do you still experiance these issues?
     
  12. F3RULLO14

    F3RULLO14

    Joined:
    Oct 14, 2013
    Posts:
    57
    No, no issues when I use StartServer. Not the MM CreateMtach. I can connect to the server via StartClient and my connection isnt dropped.
     
  13. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    So my theory was correct. You are exceeding the relay bandwidth after the grace period.

    However, if you are using Dedicated Server. Then why even bother with the relay?
     
  14. F3RULLO14

    F3RULLO14

    Joined:
    Oct 14, 2013
    Posts:
    57
    I use it to host the server list for my game. Kinda like Rust or Unturned does.
     
  15. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    I would suggest only using their matchmaker if possible and not relay. Otherwise, you could create your own or use another one. Steam has a free one, Playfab has one if you use their backend. There is a dirty one i wrote quickly for dev testing on my github in my signature. You can write a proper one from that if you want to. As inspiration.
     
  16. F3RULLO14

    F3RULLO14

    Joined:
    Oct 14, 2013
    Posts:
    57
    What do you recommend then to host a server list? I don't want to use a Minecraft system lol.
     
  17. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    I just recomended a few. Either make your own. On my github there is one you can use for dev testing,
    Steam has a free one
    Playfab have one.

    But if you are not planning to use either steam or playfab as backend I would suggest you to make your own.
     
    F3RULLO14 likes this.
  18. F3RULLO14

    F3RULLO14

    Joined:
    Oct 14, 2013
    Posts:
    57
    Alright, thank you for your help.