Super quick Timeout disconnections

I’m trying to create a multiplayer lobby, but I’m having difficulties with the connection.
I create a match at the host, then connect a client to that match.After only ~15 seconds, the client disconnects with a Timeout error, and I can’t do anything to avoid that. Host keeps connected ok.

This is the error I get:

MatchMakingClient DropConnection :https://mm.unet.unity3d.com/json/reply/DropConnectionRequest
ClientDisconnected due to error: Timeout

Just for the record, these are the operations I’m doing for this to happen:
Host:

StartMatchMaker();
matchMaker.CreateMatch("MatchName", 4, true, "", "", "", 0, 0, OnMatchCreate);

Client:

StartClient();
StartMatchMaker();
matchMaker.ListMatches(0, 6, "", true, 0, 0, OnGUIMatchList);
       
[...]
       
matchMaker.JoinMatch(mMatchNetworkID, "", "", "", 0, 0, OnMatchJoined);

I’ve configured ConnectionConfig like this at the Awake (I’m not sure if I need to do something more after this):

ConnectionConfig myConfig = new ConnectionConfig();
myConfig.NetworkDropThreshold = 50;         //50%
myConfig.OverflowDropThreshold = 10;         //10%

I’ve also tried making Command and RpcClient calls every x seconds in the LobbyPlayer that instantiates when joining a mtach, to keep messages coming, but client still disconnects after 15 seconds which is very little time.

What am I doing wrong? How can I keep the client connected to the match for enough time for the game to starts?
Thanks for your time!

Try configuring the timeouts/config in the NetworkManager in the Inspector. Default value is a bit low (I think 1 or 3 seconds?). So either your internet/server is a bit laggy and the default values are too low, or it might be a matchmaker bug?

I’ve tried playing around with Timeout values and other ConnectionConfig settings, but it still disconnects in ~15 seconds.
I’m testing with several localhost instances, so it couldn’t be a bad connectivity issue, right? I don’t know what else can I try to keep the clients connected in a match…

Localhost shouldn’t see any timeouts, you should probably report the bug then

Thing is, with the Network Lobby demo from the asset store (Network Lobby | Essentials | Unity Asset Store), this does not occur. I’m trying it on the same project, event same scene, and my approach to the lobby causes timeouts, and the asset store one works fine. So I don’t think it’s a bug, but something I’m missing

Ok, for anyone interested, I think I managed to find what was causing the disconnections. On the client side, when retrieving the server list (available matches), I did something like this:

StartClient();
StartMatchMaker();
matchMaker.ListMatches(0, 6, "", true, 0, 0, OnGUIMatchList);

Turns out that the first instruction (StartClient) is not necessary, in fact that’s what was causing the disconnections. Maybe the client thinks there are 2 connections to listen (normal client and matchmaker client), and only one of them remains connected, so it throws a Timeout error. If I remove it leaving only the matchmaking part:

StartMatchMaker();
matchMaker.ListMatches(0, 6, "", true, 0, 0, OnGUIMatchList);

then all works fine and the connection remains active.

Hope it helps anyone in the future!

2 Likes

Hello i am from the Future your answer helped me a lot and saved me quite some time so thank you very much.