-
Notifications
You must be signed in to change notification settings - Fork 690
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
Websocket timeout #29
Comments
hi @davidklodner , thanks for the issue. |
@adshao Try setting a pong handler and sending the server a ping. If the server correctly implements the websocket protocol, then the application should receive a pong. This may not be documented because it's at the Websocket protocol level, not part of the application. |
@claudia-jones thanks for the update, you are right, we can periodically send ping message to server, and check pong message for connection stability. |
Hi! Any updates on this? |
hi @kustov-an , will implement it soon. |
I don't think we need ping/pong handler here, instead, HandshakeTimeout https://godoc.org/github.com/gorilla/websocket#Dialer and CloseHandler https://godoc.org/github.com/gorilla/websocket#Conn.SetCloseHandler are enough to check connection stability. |
Correct me if I wrong, but as I understand
|
hi @kustov-an , if the connection is lost, ReadMessage will return error: https://github.com/adshao/go-binance/blob/master/websocket.go#L45, so we can use errHandler here. |
close as solved |
@adshao your project has been a tremendous help. Much appreciated. I recently started seeing many "websocket: close 1008 (policy violation): Pong timeout" messages. I see that this case is closed, but I wonder if this is something you or anyone else is seeing. My code simply restart the a Websocket, but I wonder if I should be doing something diferent. |
this is because #50 does not fix the problem, as it sends |
For future readers, as per @snawaz looks like if you set custom ping handler it will not automatically send pong based on the Gorilla websocket implementation. You will need to send pong back by yourself from within your custom ping handler. This primarily required for the implementation on the gorilla websocket with custom handler. Note that if no handler is passed or no SetPingHandler called, it will default to the default ping handler |
That's correct. I have a custom ping handler which sends |
I also encountered this error when I used gorilla/websocket to subscribe to Binance's websocket data. After a long period of testing, I finally found that it was because I subscribed to too many symbols at the same time.
The Binance document says that a connection supports up to 1024 streams. |
Hi adshao, first of all thanks for your work. Really appreaciated. I just wanted to ask you if there's a connection timeout or ping/pong mechanism to ensure connection stability?
The text was updated successfully, but these errors were encountered: