colyseus / colyseus-unity-sdk

⚔ Colyseus Multiplayer SDK for Unity
https://docs.colyseus.io/getting-started/unity-sdk/
MIT License
371 stars 102 forks source link

Session expired when attempting to reconnect #166

Open LeCommandeur opened 3 years ago

LeCommandeur commented 3 years ago

Hi!

I have been trying to implement automatic reconnection with colyseus but have been unsuccessful so far. When I disconnect one of my clients and try to reconnect the same client (basically, I close the application and relaunch it) the reconnection fails with the message "session expired: SESSION_NAME" along with the error code 4214.

The server is still running, there is still another client connected and I have added the line await this.allowReconnection(client, 60); in my onLeave() method. I attempt the reconnection within the 60 following seconds (usually 4 or 5 seconds after closing the app.)

When the 60 seconds have passed, the remaining client connected to the server realizes someone is missing and the app displays a special screen indicating someone left the game.

I'm pretty sure I provide the correct roomId and sessionId but the Client.Reconnect() method still throws an exception. Any idea as to what the problem could be? Thanks in advance!

Environment: Colyseus: 0.14.0 Nodejs: 12.18.2 Windows 10 21H1