python-binance
python-binance copied to clipboard
Error running sample websocket code
Describe the bug When I run (part of) the example ThreadedWebsocketManagerCode, I get an error.
To Reproduce Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.
from binance import ThreadedWebsocketManager symbol = 'BNBBTC' twm = ThreadedWebsocketManager() twm.start() streams = ['bnbbtc@miniTicker', 'bnbbtc@bookTicker'] def handle_socket_message(msg): ... print(f"message type: {msg['e']}") ... print(msg) ... twm.start_multiplex_socket(callback=handle_socket_message, streams=streams) 'streams=bnbbtc@miniTicker/bnbbtc@bookTicker' Task exception was never retrieved future: <Task finished name='Task-5' coro=<ThreadedApiManager.start_listener() done, defined at C:\Program Files\Python39\lib\site-packages\binance\threaded_stream.py:42> exception=KeyError('e')> Traceback (most recent call last): File "C:\Program Files\Python39\lib\site-packages\binance\threaded_stream.py", line 52, in start_listener callback(msg) File "
", line 2, in handle_socket_message KeyError: 'e'
Environment (please complete the following information):
- Python version: 3.9.2
- Virtual Env: command prompt
- OS: Windows 10
- python-binance version: 1.0.15
I have the same problem. I think it's because of python removed a parameter for async Queue method.
The problem is already fixed in websockets==10.0+.
But you cannot simply install the new version of websockets
python-binance 1.0.15 requires websockets==9.1
But you cannot simply install the new version of websockets
python-binance 1.0.15 requires websockets==9.1
So, python-binance needs to be updated to use websockets 10+?
yes, they have to update it. I read they didn't because of a bad comunication with AWS using websockets 10.0, but they fixed it in 10.1 So... i think python-binance could update to websockets 10.1
This has not been fixed as of February 2022.
same problem here , upgraded to websockets 10.1 and still not working.. was anyone able to fix it , or AVOID IT ?
Same problem: python-binance==1.0.16 && websockets==10.3
Any update on this issue?
Any update on this issue?
No updates as I'm following. You can try ccxt untill the issue is resolved.
Is there any workaround, like using BinanceSocketManager ?
Any solution yet
Use a lower version, v15 preferably
As far as I know python 3.9, 3.10 + it's not that compatible with python 15 and 16. For me it's working with python 3.8 environment and binance-python==1.0.15 and websocket 9.1