sammchardy / python-binance

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

Websocket Disconnecting in docker #944

Open rezaya92 opened 3 years ago

rezaya92 commented 3 years ago

Describe the bug I'm running Django with docker and using a futures account websocket in it. the websocket simply doesn't work most of the times meaning I start the websocket and everything seems fine but I receive no message. I have to restart it again and again and suddenly it starts working (if I restart it again it will not work). Also from time to time my websocket throws an exception and disconnects. I don't get any exception if I run the app with python 3.9 in my ubuntu without docker

Environment:

Logs or Additional context here's the exception

web_1  | Traceback (most recent call last):
web_1  |   File "/usr/local/lib/python3.9/site-packages/binance/threaded_stream.py", line 52, in start_listener
web_1  |     callback(msg)
web_1  |   File "/usr/local/lib/python3.9/site-packages/binance/streams.py", line 216, in __aexit__
web_1  |     await super().__aexit__(*args, **kwargs)
web_1  |   File "/usr/local/lib/python3.9/site-packages/binance/streams.py", line 71, in __aexit__
web_1  |     await self._conn.__aexit__(exc_type, exc_val, exc_tb)
web_1  |   File "/usr/local/lib/python3.9/site-packages/websockets/legacy/client.py", line 612, in __aexit__
web_1  |     await self.protocol.close()
web_1  | AttributeError: 'Connect' object has no attribute 'protocol'
bani24884 commented 2 years ago

I bumped into the same issue in which the WebSocket did not return responses. in my case, I downgraded the base image to python 3.8, and issue was resolved.