sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
6.09k stars 2.21k forks source link

[Update]: Websocket client inconsistency issue #724

Open wiseinvoker opened 3 years ago

wiseinvoker commented 3 years ago

There are several method in Binance Socket Manager to subscribe klines, tickers, etc. I think the websocket functionality is inconsistent and sometimes it raises Maximum connection reached error when trying to subscribe websocket streams while other websocket client (using websocket-client) connection to the Binance Stream works very well. If I subscribe Binance websocket stream using JavaScript in browser, it never raises maximum connection reached error. But If I use this library python-binance to subscribe kline or ticker stream, I sometimes face maximum connection reached error.

Using python-binance

conn_key = bm.start_kline_socket('BNBBTC', process_message, interval=KLINE_INTERVAL_1MINUTE)
conn_key = bm.start_multiplex_socket(['bnbbtc@aggTrade', 'neobtc@ticker'], process_m_message)

Using websocket-client

ws = websocket.WebSocketApp("wss://stream.binance.com/ws/btcusdt@kline_1m", on_message=on_message)
ws.run_forever()

Why not using websocket-client module to manage binance websocket streams?

oliver-zehentleitner commented 3 years ago

There are limits set by binance: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/wiki/Binance-websocket-endpoint-configuration-overview

Jex.com allows only 10 subscriptions...

So i guess thats not a fault of this lib!