Error: session outgoing queue full

Hello,
In my real-time nakama server game, i send player positions on Update method inside of Unity.
After couple minutes, nakama server broken with this error:
{"level":"error","ts":"zzz","msg":"Failed to route message","uid":"xxx","sid":"xxx","sid":"xxx","error":"session outgoing queue full"
Related source code: https://github.com/heroiclabs/nakama/blob/acffaf09aa0af1b650e7edce2a12a80e67b40d75/server/session_ws.go#L36
Build: WebGL
Any suggestions? Thanks.

I fixed this problem with FixedUpdate method. (Update call : 186, FixedUpdate: 50)

Hi @halukdemir. This is not a “broken” problem with the server. What it means is that the buffer the server maintains for the client device cannot keep up with the number of messages placed into its outgoing message buffer.

You’re sending too many messages from the server to the game client. There’s only so many messages a game device can receive per second. You should be conscious of this data flow in the design of your game.

H @novabyte
I’m sorry to bother you.
I got this problem today, I’m on the way to reducing the number of messages. However, I have a question to ask: The server always closes the client connection when this problem occurs, how to avoid the connection being closed when “session outgoing queue full”?

{
caller
server/message_router.go:96
error
session outgoing queue full
level
error
mid
6742221f-cecd-444c-a4b4-b6dd479bfce2
sid
f9fbf67d-13a6-11ed-a924-cd5958faadd2
ts
2022-08-04T03:39:58.242Z
}

Once the outgoing queue reaches its capacity, we choose to close the client connection because it’s the best option we have given the alternatives.

You can adjust the capacity of the queue but it uses more memory and bad actors can fill it to degrade your server performance: Nakama: Configuration | Heroic Labs Documentation

Ultimately the rate at which the buffer fills and drains is a function of messages to send, client connectivity and client CPU (how fast it processes its incoming queue so it can notify the server.) The easiest of those factors for you to adjust is the number of messages that the server must send to begin with.