websocket icon indicating copy to clipboard operation
websocket copied to clipboard

After a long time of listen, the Binance will close ws connection [question]

Open ybina opened this issue 2 years ago • 2 comments

After a long time of listen(more than 10 hour), the Binance will close ws connection, and should redail the connection, if not, will receive a lot of read err msg.

Is there any way to avoid this problem?

ybina avatar Aug 10 '22 08:08 ybina

@ybina hello, are you talking about https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md ?

If yes, the link above mentions:

A single connection to stream.binance.com is only valid for 24 hours; expect to be disconnected at the 24 hour mark

So it seems normal that binance WS API disconnects connection from time to time. From the client perspective you need to handle Read error and reconnect to a server.

FZambia avatar Aug 10 '22 09:08 FZambia