melody icon indicating copy to clipboard operation
melody copied to clipboard

Example for implementing idle session timeout

Open omerkirk opened this issue 2 years ago • 4 comments

Hi,

Thank you for a great package, it is much cleaner and simpler to use compared to gorilla/websocket library.

I am developing a game server and need to implement an idle timeout, I've set PingPeriod and PongWait values however it doesn't timeout the session or close the connection. In the readme feature list it looks like this is included "Automatic handling of ping/pong and session timeouts" however I can't seem to get it to work. Can you add an example that includes a simple implementation.

omerkirk avatar Sep 22 '22 14:09 omerkirk

The doc is a little confusing but the automatic ping/pong handling is for Websocket heartbeats which time out broken connection (i.e sessions that don't respond to the control frame 'ping').

olahol avatar Sep 26 '22 15:09 olahol

That is right thank you, we are doing some cleanup on HandleDisconnect for each session and we realized there are sometimes sessions that are no longer available but the cleanup process didn't run for some reason. We are looking into it, our current understanding is in some cases HandleError runs but disconnecthandler is not called. I will update this issue when I complete debugging.

kokteyldev avatar Sep 28 '22 08:09 kokteyldev

That is right thank you, we are doing some cleanup on HandleDisconnect for each session and we realized there are sometimes sessions that are no longer available but the cleanup process didn't run for some reason. We are looking into it, our current understanding is in some cases HandleError runs but disconnecthandler is not called. I will update this issue when I complete debugging.

I have the same problem. Have you solved your problem?

youngsailor avatar Mar 08 '23 13:03 youngsailor

In v1.1.2 HandleDisconnect should now run more reliably.

olahol avatar Mar 08 '23 15:03 olahol