Hello, I believe I found a bug with Unity Netcode. I am using custom named messages, WebSocket with encryption, WebGL clients and a dedicated Linux server. So to replicate this you have to connect the clients to the server and while the server is broadcasting a custom named message and a client disconnects due to internet disconnection, the Netcode server freezes.
The error that I get:
Error sending message: Unable to queue packet in the transport. Likely caused by send queue size (‘Max Send Queue Size’) being too small.
CompleteSend failed with the following error code: -5
The rest of the functions work as intended, CPU and RAM usage are at normal levels, it’s just the Netcode that gets frozen. I prepared the project files and uploaded on Github: GitHub - Fobal/Unity-NGO-DisconnectionBug
How to replicate:
Setup the ip,port,serverCommonName on ClientManager and the port,certificates on the ServerManager. Build a linux dedicated server and webGL for clients. Connect at least 2 clients. Then while the server sends the custom message, just disconnect one client (by losing internet access).
What exactly do you mean by “while”? It’s not like this operation will take several seconds. But just in case it does, then I wouldn’t be surprised about the “send queue size” being too small.
How much data are you trying to send? There’s a send limit per frame which I believe is well under 64kb.
1 Like
Noticed this in the source code:
private const int MSG_SIZE_MAX = 1024 * 1024 * 10; // 10MB
It’s not a bug, it’s just “too much”.
Netcode isn’t meant to support high volumes of traffic. Sending this much data requires splitting it up into dozens of chunks (smaller than send queue size since there needs to be room for other, regular traffic too) and waiting for acknowledgement from clients before you send another chunk. This will slow down sends significantly. Such large data should be saved to a webserver location by the server with the clients receiving the URL and downloading that file themselves.
1 Like
Hello, 10MB is just a ridiculous max cap, that I set, which is never reached. The actual data sent are on the file CustomMessageNames.cs and the fields are these:
public bool bool_value;
public int int_value;
public ulong ulong_value;
I believe this is a tiny packet and it definitely doesn’t reach the cap you mentioned.
The server sends a message every 0.2s to all clients and when someone disconnects, the netcode freezes, that’s what I meant with “while”. Thank you.
I understand. Yes that packet shouldn’t cause any issues.
Did you hook into all the network events? Primarily client disconnect / stopped and transport failure? Though the latter, if raised, will inevitably shut down the NetworkManager.
You could also test with a desktop client (still with websocket enabled) to see if this is browser specific behaviour.
Be sure to report bugs on the NGO GitHub page too.
1 Like
The issue is down to the way you are ‘disconnecting’ the client. Since you are ‘losing internet access’ the client isn’t removed from the server properly and it continues to try and send the RPC to the client.
Since they are reliable they will continue to stack up eventually max out the packet queue ‘Max Packet Queue Size’ in transport settings with a 30 second timeout it’s going to add up fast.
If you set the ‘Disconnect Timeout MS’ in transport to 1000ms it should fix it. Typically you want the timeout as small as you can possibly make it to avoid these types of issues.
3 Likes
Really on point
This wasn’t an issue in UDP. It would be great to know why
Also shouldn’t the Netcode server “force” empty the queue by itself to continue working? Freezing the server isn’t ideal for live games. Especially when there are 100+ players connected to that server.
Thank you for the answer! Really helpful, I recently tried 5000ms on ‘Disconnect Timeout MS’, it improved a lot but still happens.