Versions: Nakama {3.23.0}, {unity client SDK: v3.13.0}
Server Framework Runtime language {Go}
Unity Version 2022.3.36f1
We are facing an issue with Nakama’s handling of disconnected clients in a server-authoritative match. Here’s the setup:
- Max Match Play Duration: 120 seconds
- Reconnection Timeout: 10 seconds
The custom logic for reconnection is working as expected, allowing players to rejoin matches successfully. However, the MatchLeave event gets triggered approximately 15 seconds after a disconnection, even if the player has already rejoined. This results in the player being kicked out of the match.
While we could add a check to prevent kicking players who have rejoined recently, this feels more like a workaround. It could complicate scenarios where a player genuinely disconnects multiple times in a short period.
Is there a way to lower the time Nakama takes to detect and trigger MatchLeave for disconnected clients?
Any guidance or best practices would be greatly appreciated!
@surajTLabs if MatchLeave
is only triggered 15 seconds after socket disconnection then it’s likely that there’s some infrastructure or OS issue that is preventing the Go process from detecting the disconnection - I assume you’re running on custom infrastructure? On Heroic Cloud we’ve not observed this sort of delay between socket disconnection and MatchLeave
firing.
I noticed an interesting thing on changing following values in server config solves above particular issue
socket.ping_period_ms = 15000 ---> 3000
socket.pong_wait_ms = 25000 ---> 3500
Tuning those configs may help for your specific issue, but if the socket was actually disconnected (assuming it wasn’t a network issue) the underlying OS network stack should surface disconnection early rather than having to timeout on ping/pong values. The tradeoff is that lowering those configs may reduce tolerance to transient network issues on unstable connections in a production setting. If the tradeoff works well enough in practice then I’m glad you found a solution.