You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
no doc related to hearbeat use case when connection is for push only events #492
right now according to doc you have to read from connection to fire SetPongHandler event. But if the websocket is used for push only it won't be fired. Solution is to use:
go ws.NextReader()
But the doc is not very straight forward about that. In my opinion there should be description of how to setup heartbeat in case of push only usage. Let me know if you need help with that.
The read operation is blocking so c.Close() might not ever happen for unresponsive client. Therefore I think it's not right way to implement heartbeat procedure. I think it should be explicitly described procedure of using:
websocket.Conn.SetPongHandler for registration of last PONG time from client
websocket.Conn.NextReader() for reassurance that PONG is even obtained
websocket.Conn.WriteMessage(websocket.PingMessage, ...) for sending PING and checking if there is no socket issue
I'm not saying that there is no documentation. I'm just saying that this common use case is not covered as whole neither by examples nor by documentation. All breadcrumbs are separated ;)
It takes me at least 2h to figure out how to do it right. So I can create example to save time of others working on similar case. Does it sound reasonable?
Activity
jjuraszek commentedon Mar 19, 2019
The read operation is blocking so
c.Close()might not ever happen for unresponsive client. Therefore I think it's not right way to implement heartbeat procedure. I think it should be explicitly described procedure of using:websocket.Conn.SetPongHandlerfor registration of last PONG time from clientwebsocket.Conn.NextReader()for reassurance that PONG is even obtainedwebsocket.Conn.WriteMessage(websocket.PingMessage, ...)for sending PING and checking if there is no socket issueI'm not saying that there is no documentation. I'm just saying that this common use case is not covered as whole neither by examples nor by documentation. All breadcrumbs are separated ;)
It takes me at least 2h to figure out how to do it right. So I can create example to save time of others working on similar case. Does it sound reasonable?
elithrar commentedon Mar 19, 2020
Closing this one out for now.
ozgurakcali commentedon Nov 4, 2020
A dummy reader should not be necessary to be able to respond to ping messages IMO. Even if it is documented, it doesn't feel natural.