ServerDisconnected due to error: Timeout
Hello. I am working on a MMO game using UNet. I have a headless server running on Linux Ubuntu hosted on AWS. Clients get connected to it and players can play with each other. After about 15 to 20 minutes all clients are disconnected and server shows the following error:
Log: connection {} has been disconnected by timeout; address {::ffff:} time {2666259}, last rec time {2660314} rtt {299} timeout {5000} ServerDisconnected due to error: Timeout
As I am new to multiplayer I am unable to figure out what causes it. I am seeing the resources on AWS and everything looks fine.
Following are my timeout settings in NetworkManager:
Minimum Update Timeout: 1 ms
Connect Timeout: 5000 ms
Disconnect Timeout: 5000 ms
Ping Timeout: 3000 ms
Any help would be greatly appreciated.
Answer by IgorAherne · Feb 11, 2020 at 09:04 PM
Have a look here: http://answers.unity.com/answers/1443850/view.html
In case the original post is removed, here it is:
These are the initialization settings that worked for us:
void InitializeNetwork(){
myConfig.AddChannel(QosType.Reliable);
myConfig.AddChannel(QosType.Unreliable); myConfig.AddChannel(QosType.StateUpdate); myConfig.AddChannel(QosType.AllCostDelivery); myConfig.NetworkDropThreshold = 95; //95% packets that need to be dropped before connection is dropped myConfig.OverflowDropThreshold = 30; //30% packets that need to be dropped before sendupdate timeout is increased myConfig.InitialBandwidth = 0; myConfig.MinUpdateTimeout = 10; myConfig.ConnectTimeout = 2000; // timeout before re-connect attempt will be made myConfig.PingTimeout = 1500; // should have more than 3 pings per disconnect timeout, and more than 5 messages per ping myConfig.DisconnectTimeout = 6000; // with a ping of 500 a disconnectimeout of 2000 is supposed to work well myConfig.PacketSize = 1470; myConfig.SendDelay = 2; myConfig.FragmentSize = 1300; myConfig.AcksType = ConnectionAcksType.Acks128; myConfig.MaxSentMessageQueueSize = 256; myConfig.AckDelay = 1; HostTopology myTopology = new HostTopology(myConfig, 4); //up to 4 connection allowed NetworkServer.Configure(myTopology);
}
Also, if you are hard-coding a port, make sure it's large enough. I had port 1777 which was causing issues on Ubuntu, so changing it to 17777 helped as well.
_hostId = NetworkTransport.AddHost(topo, 17777, null);
And, if you are still experiencing disconnect, make sure you are setting ping to be frequent enough. 1000 as in the example above wasn't enough. Had to reduce it down to 150 to stop these time-outs. Obviously this will consume more bandwidth.
myConfig.PingTimeout = 170;
myConfig.DisconnectTimeout = 6000;
myTopology = new HostTopology(myConfig, 4); //up to 4 connection allowed
NetworkServer.Configure(myTopology);
Going to a higher port number totally worked for me! Thanks a million!
Your answer
![](https://koobas.hobune.stream/wayback/20220612124733im_/https://answers.unity.com/themes/thub/images/avi.jpg)