Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Timeout disconnect after a few minutes

Discussion in 'Multiplayer' started by teremy, Nov 12, 2015.

  1. teremy

    teremy

    Joined:
    May 2, 2015
    Posts:
    88
    Hello.
    I am working on a multiplayer puzzle game. I tested it with a friend ( not living close, but still a good ping ).
    Yesterday and today we tested the game for a longer period of time and somehow he gets disconnected after a few minutes. I told him to send me content of the log file, and it says the following ( changed my IP to x's ):
    In the network manager I have set timeouts to the following:
    The game doesn't create much traffic, since it's basically a turnbased game.
    Why is this happening and how am I supposed to get to the source of this problem?
    Unet is probably sending keepalive packets internally, how frequently are they sent? I am using the HLAPI.
     
  2. teremy

    teremy

    Joined:
    May 2, 2015
    Posts:
    88
    It was the ping timeout setting. 500ms was probably way to small, if you lose some packets then you get disconnect quickly. It works if I put a higher amount, but even with 30000ms ping timeout it gets disconnected when I test with 10% packet loss ( inbound and outbound ).

    Is there a way to set how frequently keep alive packets are sent? How frequently are they send, then maybe I could manually send some keep alive packets if nothing has been send for a while.
     
    Last edited: Nov 12, 2015
  3. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    I also find it difficult to fully understand the latency simulation behaviour and I have experienced disconnects with simulated packet drops of only 1%. More documentation seems to be needed here.
     
  4. teremy

    teremy

    Joined:
    May 2, 2015
    Posts:
    88
    I found this: http://issuetracker.unity3d.com/issues/disconnect-with-10-percent-packet-loss-and-unreliable-packets
    Even with 5% packet loss the client can get disconnected (easily) although I am using a very high ping timeout ( like 30 seconds ) and also you with 1% packet loss!
    This needs some work, since Ping Timeout won't have any affect on packet loss, so a client gets disconnected way to easily. I don't even know how exactly the timeout is defined for unity. Would also be great to know how frequently keep alive packets are being sent and/or if sending packets has any effects on this ( maybe if you haven't send anything for some time one could manually send "keep alive" packets, don't know if this would change anything ).
     
  5. gskronn

    gskronn

    Joined:
    Nov 17, 2012
    Posts:
    4
    Just to add another voice to this: I am seeing the same behavior. More or less random disconnects running two instances on the same machine. This even happens when not using the network simulation. The only way to work around it right now is to set ridiculously high values for Ping Timeout AND Disconnect Timeout (upwards of 50000 ms). With those it so far seems to not disconnect all the time anymore.
     
  6. teremy

    teremy

    Joined:
    May 2, 2015
    Posts:
    88
    Yeah, if they don't change it I will use something else than unet. Who wants to play a game where you might get disconnected after a short time?
     
    gamedev42 likes this.
  7. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    651
    The free UNET matchmaking allows for very little bandwidth (4k/s + 2min initial buffer) and once you hit a quota it will disconnect you. See this thread.
    http://forum.unity3d.com/threads/matchmaker-client-timeout.342745/

    So if you use a stopwatch and it disconnects you at the exact same time each game (i.e. after exactly 1 minute 14seconds or something very repeatable) then it is likely a bandwidth quota issue.
     
  8. teremy

    teremy

    Joined:
    May 2, 2015
    Posts:
    88
    We are not using UNET's matchmaker.
     
    gamedev42 likes this.
  9. Sophung

    Sophung

    Joined:
    Nov 12, 2012
    Posts:
    1
    I have this problem too, but I think I found a solution:

    Change channel QoS to ReliableFragmented and change the connectionConfig of the NetworkManager to something like this:
    connectionConfig.IsAcksLong = true;
    connectionConfig.MaxSentMessageQueueSize = 1024;
    connectionConfig.MaxCombinedReliableMessageCount = 1;

    You should change the connectionConfig in the beginning of the Start() method of your NetworkManager before you call any StartServer/StartClient/StartHost.

    Also, it seems that it is good to use a lot of channels. I used one channel per NetworkBehaviour subclass I had in the game. In my project I had 6 NetworkBehaviour subclasses, so I set 6 ReliableFragmented channels on my NetworkManager and then used the NetworkSettingAttribute to assign a channel to a class. For example:

    [NetworkSettings(channel = 0, sendInterval = 0.1f)]
    public class Team : NetworkBehaviour

    [NetworkSettings(channel = 1, sendInterval = 0.1f)]
    public class Patron : NetworkBehaviour

    [NetworkSettings(channel = 2, sendInterval = 0.1f)]
    public class Item : NetworkBehaviour

    ...

    [NetworkSettings(channel = 5, sendInterval = 0.1f)]
    public class GamePlayer : NetworkBehaviour

    So far I haven't had these disconnection problems with this solution. Tested with 15 minutes runs. Will test with longer runs. This solution also solved a problem I had with very irritating 5~10 seconds delays that occurred whenever the client sent a Command and then waited for the server to send a response Rpc, as well with some unexplainable general lagginess and latency even though I'm testing with all clients in the same wifi but separate machines (and no, I don't have NetworkSimulation on).
     
  10. JoeTheGG

    JoeTheGG

    Joined:
    Aug 18, 2013
    Posts:
    42
    @Sophung were you able to verify if that fixed it for you?
     
  11. soaring

    soaring

    Joined:
    Jun 22, 2015
    Posts:
    27
    We've been having disconnect issues when using the networkSimulation (400ms delay, no packet loss) and testing the server & clients both on the same machine.

    We've tried tweaking ping time to 1000ms and incorporating the ideas from @Sophung, but none of them seem to be working for us. And when we changed our ping timeout to 2000ms, it actually disconnected VERY quickly.

    Is networkManager's network simulation a valid test? Does anyone else have suggestions? Our plan is eventually to run this for mobile phones over cellular data network...
     
  12. srylain

    srylain

    Joined:
    Sep 5, 2013
    Posts:
    159
    Try changing NetworkManager.singleton.connectionConfig.NetworkDropThreshold to 90 or so, like this:

    NetworkManager.singleton.connectionConfig.NetworkDropThreshold = 90;

    You want to put that somewhere that's ran before you create your server/client. What's happening is that the default value is set to 5, so if you have 5% or more packet loss it keeps decreasing the send rate which eventually will put you above the ping timeouts (which causes a disconnection).
     
  13. leoncorrl

    leoncorrl

    Joined:
    Apr 27, 2014
    Posts:
    15
    This work for my card mobile game...
     
  14. scottlaforge

    scottlaforge

    Joined:
    Mar 12, 2013
    Posts:
    42
    I was curious if anyone has found any reliable advice for the settings needed using UNET to prevent the clients from constantly being disconnected? We are still using the free UNET relay server service along with the matchmaking services. I've tried modifying the connectionconfig.NetworkDropThreshold, along with all of the timeouts. I also tried adding additional network channels. The best results have been from modifying the Disconnect Timeout to an obscene 20,000 ms, at which point it lasts approximately 6 minutes. But when the player purposefully disconnects, it takes forever to actually see them leave.

    Any help would be greatly appreciated.
     
    n1ckfg likes this.
  15. U-GeeN

    U-GeeN

    Joined:
    Mar 22, 2015
    Posts:
    95
    Hi everyone,

    stupid question...
    I'm using the standard NetworkLobbyManager script.
    What is a appropriate place to put this magic line in?
     
  16. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    @scottlaforge , first of all try to use the last version of library, i totally removed NetworkDropThreshold from config (means this parameter doesn't affect anymore to disconnecting). Another reason, Relay server throttles bandwidth, how many bytes do you send per sec?
     
  17. gamedev42

    gamedev42

    Joined:
    Jan 17, 2017
    Posts:
    3
    Could you provide meaningful documentation, please? Because as of now, nobody will use your system, if they don't understand exactly why things like this occur. We tried everything: changing amout of packets, channels, optimizing synced variables. But nothing works. Our client get stable disconnection after a few minutes. This is unacceptable for us.

    We are using UNET for prototyping FPS game, but we found so many bugs and inconveniences that we probably will skip this unstable piece of software and make our own. How hard is that to transfer few kb/s over the sockets?
     
  18. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    Hm, NetworkThreshold has been described in script reference API, did you check there?

    But, totally agreed with you about documentation, it is persistent pain for me too, to create tutorial and manual about llapi and configuration. I cannot say I promised to make it in one week (in one month too) but will try. So far (as I bad guy) you can ping me directly...
    =Alex
     
    Zullar likes this.
  19. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    177
    @aabramychev I'm experiencing a very similar issue !

    Since we don't have any idea about bandwidth consumption (no bandwidth visualization / no UNet query about bandwidth to debug this disconnection issue) + the leack of documentation. We are left with a huge opaque window with a lot of questions and just few answers... which is very frustrating...

    In my case I'm pretty sure is about bandwidth limitation. the only parameter that seems to make things better is settings AcksType to 128.. but still getting client disconnect ! I'm using networktranform so I guess the need of sending keep alive is useless in my case..

    I tried to optimize all of my synced data and keep it as minimalistic at it should but still I need to sync all the networked scene object on client join and I have a lot of them (trees, rocks, food, building parts ...)
    Please see my unanswered post here https://forum.unity3d.com/threads/a...ted-issue-after-updating-to-unity-5-6.472288/

    Any help will be much appreciated
     
  20. chris-nolet

    chris-nolet

    Joined:
    Feb 18, 2014
    Posts:
    13
    I'm on version 5.6.0f3 and getting the same random disconnects after a few minutes at most. I'm sending data down the unreliable channel only, so AcksType/IsAcksLong isn't a factor, and increasing both NetworkDropThreshold and OverflowDropThreshold to 90 doesn't help at all.

    Is there a fix, or better to switch to Photon?
     
  21. gamedev42

    gamedev42

    Joined:
    Jan 17, 2017
    Posts:
    3
    There is no fix atm. We have switched to Photon for production. But, I think, if you use low level UNET API exclusively for the transport purposes, it may be okay. We thought about this idea for some time, but unfortunately we have to make the actual game instead of sitting still thinking about UNET internals.
     
  22. lauraaa

    lauraaa

    Joined:
    Dec 30, 2016
    Posts:
    16
    Hi @aabramychev, could you verify that NetworkDropThreshold doesn't work any more? Cuz it still exits in config, based the official documentation. And would you have any ideas what causes this unreliable connection? Thanks in advance!
     
  23. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    Confirmed - it calculates, but not used for bandwidth throttling.
    before 5.6.1p3 it could be disconnect, but that bug was fixed in 5.6.1p3. Check please
     
  24. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    160
  25. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    @jjobby should be. 5.6 is a single dev. line, so all fixes for 5.6.1xx should be automatically included in 5.6.2xx

    the was another problems with 5.6.2xx and the last one (from these problems) was fixed for 5.6.2p3 (which has been published today or yesterday) check them please, everything should work

    =Alex
     
  26. LangTao92

    LangTao92

    Joined:
    May 13, 2017
    Posts:
    15
    2018.1.0 client disconnect to server too
     
    Zaicheg likes this.