-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ping msg timeout detection #37
Comments
Hi, @cert-lv. You are a guy who sent email to me about the issue, aren't you? 😁 If you want to detect session's timeout that is occured by ping-pong, I think that it would be detected in using HandlePong method and HandleClose method in combination. |
Hello, @shiwano. I was thinking more like about low latency detection, when client connection is slow, but still exists, not closed. Current solution could be calling m.Broadcast(msg) to send an additional message with timestamp as payload, in a loop. Then in HandleMessage() check the diff with current timestamp. But then one more ping-like message will exist. Better solution could be to use already existing ping messages. According to the WebSocket protocol, ping message can include optional payload and client/browser must send back the same payload. Currently Melody doesn't use this payload. Would you like to include this functionality? Simplest solution is just to include current timestamp in every ping message. Universal solution is to allow any custom payload. Package users could do then something like: m.SetPingData(func(s *melody.Session) []byte {
// TODO: Set timestamp as []bytes here
return []byte("hello")
}) ... to set their custom payloads. After that process incoming data: m.HandlePong(func(s *melody.Session, data []byte) {
log.Println(string(data))
}) |
Ah I see! If measuring websocket connection latency is what you want to do, I think that it makes sense to use ping message. Now it can not do, but I also guess it would be good that melody do that. https://github.com/vtortola/WebSocketListener/wiki/Measuring-WebSockets-connection-latency |
There is still no concrete solution, is there? |
Line 71 in 87e736d
I can't get the message after the browser sends it, but I implemented a client using golang that finds that it can receive the message,but it was a null value,A null value causes the browser to filter out the message。 |
Hi,
Melody has a ping-pong functionality to keep the connection open and there is a config option PongWait. But how can I detect timeouts? For example, if client's network connection is or becomes too slow - how can I detect it with Melody?
The text was updated successfully, but these errors were encountered: