adshao / go-binance

A Go SDK for Binance API
MIT License
1.48k stars 664 forks source link

UserData socket closes every 2 minutes #496

Closed jokaorgua closed 1 week ago

jokaorgua commented 11 months ago

Hello. I have a strange issue with UserData websocket I start it like this

for{
     futures.WebsocketKeepalive = true
    doneC, _, err := futures.WsUserDataServe(listenKey, userDataEventHandler, errorDataEventHandler)
    <-doneC
}

when I run it from my laptop everything is ok. But when I try to run from server I get disconnects every 2 minutes. (error in console (*net.OpError)(0xc0004a2050)(read tcp XXX.XXX.XXX.XXX:36094->13.112.178.104:443: use of closed network connection))

Any help and ideas would be appreciated.

P.S. I do not see a way to send 'ping-pong' by requesting balance through UserDataStream ws connection (https://binance-docs.github.io/apidocs/futures/en/#websocket-user-data-request)

jokaorgua commented 11 months ago

the most interesting thing that I've tried from another server (different hoster, different location) and it works okay like from laptop

jokaorgua commented 11 months ago

so after a huge amount of tests I've figured out that binance has some kind of problems with vultr japan DC (vultr is my hoster). It closes connection after 2-3 minutes since the last data timestamp sent through this connection.

So the ability to request balance or account data through UserDataStream would be wonderful. This will keep connection alive.

xyq-c-cpp commented 1 week ago

No response for a long time, close this issue