Search Unity

NetworkTransport disconnect every 40 seconds

Discussion in 'Multiplayer' started by Nimred, May 10, 2016.

  1. Nimred

    Nimred

    Joined:
    Nov 1, 2014
    Posts:
    46
    Hi,

    I'm using the NetworkTransport API for a turn-based game, in pretty much the same way as this tutorial explains: http://www.robotmonkeybrain.com/good-enough-guide-to-unitys-unet-transport-layer-llapi/
    I have only two players, they successfully connect to each other by IP (not matchmaking), and successfully exchange messages every second or so.

    However, every 40-50 seconds, the clients receive "Disconnect" messages, with the error number 6, aka "Timeout". The disconnects don't happen simultaneously on each client. Every time I restore the connection following the disconnect, but another disconnect comes 40-50 seconds after connection is established.

    • I tried to crank up all sorts of timeouts in the ConnectionConfig class, without effect. Also, none of the timeout values I checked correspond to 40-50 seconds
    • I tried clients on the same local network and different networks, without effect (except in the timeout value, which was exactly every 37-38 seconds on different networks, but was variable between 40-50 on LAN). It also happens when both clients are on the same computer.
    • I tried different channel types: Reliable (which is what I want), Unreliable, AllCostDelivery. It made no difference.
    • I looked up the forums, google, answers, but while others seem to have similar problems, no solution has been mentioned.
    I don't think I'm doing anything wrong, unexpected or special with my code. Pretty much basic peer to peer. Does anyone know if this is a bug with Unity, or if there's a hidden setting that must be changed in order to make multiplayer work?

    PS: I'm on Unity 5.3.3f1
     
    Last edited: May 10, 2016
  2. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    Increase networkdropthreshold up to 40 or more
     
  3. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    If it wont work or you obtain disconnects workin on the same computer generate bug please. I need to check, but most probably (if you have disconnect on loopback) something wrong with your script. If you able prepare short script wich able reproduce this problen on local computer you can attach this script here and ping me, i will check. It will much faster than go through the bug report, but unfortuntale i do not have much time to change your project, so it should be as simple as possible which will save my time to reproduce your problem. If is all what i cn do, sorry that i cannot do more :(

    Alex
     
  4. Nimred

    Nimred

    Joined:
    Nov 1, 2014
    Posts:
    46
    Increasing networkdropthreshold had no effect, and yes the problem also happens with two clients on my computer. I will try to strip my project down to one script and get back to you. Thanks!
     
  5. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    Ok will wait for you, do not forget ping me to avoid this thread loss :)
     
  6. Nimred

    Nimred

    Joined:
    Nov 1, 2014
    Posts:
    46
    Networkdropthreshold did the trick after all. Apparently some of the timeouts I had increased to try to fix the disconnection problem between two machines were to blame for when it happens on a single machine. After resetting the timeouts to their initial values AND increasing the networkdropthreshold to 60, it worked everywhere (so far).

    I still get disconnects sometimes but they don't repeat with regularity anymore.

    Thanks for your help!
     
  7. Nimred

    Nimred

    Joined:
    Nov 1, 2014
    Posts:
    46
    It would be nice if disconnects related to the network drop threshold had a specific error message... It's impossible to know the threshold needs to be increased when the error only says "Timeout".
     
  8. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    yes, it is good idea. will do something like this or will expose api to check current dropping status. Thanks
     
  9. boxels

    boxels

    Joined:
    Oct 5, 2016
    Posts:
    7
    This is something we have been dealing with now for 2 months! Frustrating is an understatement. I have submitted a ticket to multiplayer support to see what they say. Will update if we find a solution with their Unity PRO help.

    Here is a beta test video showing the disconnect of a CLIENT to the host, doesn't matter where host is at, whether it be our Provo, UT google fiber office, or anywhere in the USA or world (we've tested them all). ALL clients disconnect almost simultaneously (within few seconds, max 10 seconds) within typically one minute to two minutes of game play.

    VIDEO (link fast forwards to 4m 43s):


    We have tested 2 players, 10 players, doesn't matter. Within one minute of any ONLINE MULTIPLAYER GAME all clients freeze in place and then disconnect within a few seconds of each other all almost simultaneously. All clients connect just fine to start. No errors displayed as to why in Game Performance.
     
  10. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    151
    Too many messages cause a timeout error because you exceed the network bandwidth maybe ?