Comments (14)
@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 ping
message whereas the client needs to send pong
message. As the per the binance docs, it's the server which sends ping
to the client and then if the client does not respond with a pong
message within 10 mins, then the server will disconnect the connection.
from go-binance.
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
from go-binance.
hi @davidklodner , thanks for the issue.
for connection timeout, do you mean readdealine as in https://godoc.org/github.com/gorilla/websocket#Conn.SetReadDeadline , I think we can add it as a websocket config; while for ping/pong handler, I cannot find any info about it from binance api doc, and I tested it with https://godoc.org/github.com/gorilla/websocket#Conn.SetPingHandler and https://godoc.org/github.com/gorilla/websocket#Conn.SetPongHandler, there is nothing sent from binance server, I think it's fine to ignore them.
Do you have any better suggestion?
from go-binance.
@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.
from go-binance.
@claudia-jones thanks for the update, you are right, we can periodically send ping message to server, and check pong message for connection stability.
from go-binance.
Hi! Any updates on this?
from go-binance.
hi @kustov-an , will implement it soon.
from go-binance.
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.
Since these changes will break the compatibility, we need to refactor the web socket interfaces.
from go-binance.
Correct me if I wrong, but as I understand
- HandshakeTimeout is only used when establishing a new connection
- CloseHandler is executed when the connection is closed by the peer
So those changes are not going to help when the connection is lost due to network problems?
from go-binance.
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.
from go-binance.
Hi @adshao, please take a look at my pull request #50 addressing this issue
from go-binance.
close as solved
from go-binance.
@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.
from go-binance.
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.
That's correct. I have a custom ping handler which sends websocket.PongMessage
, as soon as it receives the PingMessage.
from go-binance.
Related Issues (20)
- Crypto Box? HOT 1
- <APIError> code=-1106, msg=Parameter 'reduceonly' sent when not required. HOT 1
- how to keep listenKey alive? HOT 1
- when listenKey expired get error:json: cannot unmarshal string into Go struct field WsUserDataEvent.E of type int64 HOT 2
- can not get balance
- unexpected end of JSON input
- is threre subToMaster or masterToSub method?
- is there demo code to use subtoSub?
- something wrong happened when I get account asset? HOT 3
- [feat] support biance non-global HOT 2
- Support Query Margin Available Inventory
- Please do a new release HOT 10
- How to get x-mbx-used-weight-1m? HOT 2
- binance.WebsocketTimeout = time.Second * 5 Not working !
- Support for ed25519 secret/signing
- [error] msg=Invalid API-key, IP, or permissions for action. HOT 1
- [info] how to increase precision
- [Question] Trade service for delivery (futures coin) to fetch recent trades
- [issue] WsBLVTKlineServe is not returning anything
- [Question] examples needed!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-binance.