olahol / melody

:notes: Minimalist websocket framework for Go
BSD 2-Clause "Simplified" License
3.76k stars 365 forks source link

Example for implementing idle session timeout #70

Open omerkirk opened 2 years ago

omerkirk commented 2 years ago

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.

olahol commented 2 years ago

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').

kokteyldev commented 2 years ago

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.

youngsailor commented 1 year ago

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?

olahol commented 1 year ago

In v1.1.2 HandleDisconnect should now run more reliably.