sammchardy / python-binance

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

Error running sample websocket code #1082

Open k128 opened 2 years ago

k128 commented 2 years ago

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):

rever96 commented 2 years ago

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

k128 commented 2 years ago

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+?

rever96 commented 2 years ago

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

luciolle commented 2 years ago

This has not been fixed as of February 2022.

PabloBorda commented 2 years ago

same problem here , upgraded to websockets 10.1 and still not working.. was anyone able to fix it , or AVOID IT ?

pouyaGit commented 2 years ago

Same problem: python-binance==1.0.16 && websockets==10.3

guy-landry commented 2 years ago

Any update on this issue?

pouyaGit commented 2 years ago

Any update on this issue?

No updates as I'm following. You can try ccxt untill the issue is resolved.

Tigzy commented 2 years ago

Is there any workaround, like using BinanceSocketManager ?

obi-somu commented 2 years ago

Any solution yet

obi-somu commented 2 years ago

Use a lower version, v15 preferably

SorinDn commented 1 year ago

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