sammchardy / python-binance

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

Futures socket does not work with websockets version 10.0 #1023

Open DaStapo opened 3 years ago

DaStapo commented 3 years ago

Describe the bug I recently reinstalled all modules and the futures websocket suddenly stopped working (no exceptions thrown). Downgrading to "websockets==9.1" resolved the issue.

To Reproduce Install the latest version of python-binance and websockets, then the following code will get stuck at tscm.recv() client = await AsyncClient.create() bm = BinanceSocketManager(client) ts = bm.aggtrade_futures_socket('BTCUSDT') async with ts as tscm: while True: res = await tscm.recv() print(res)

Environment (please complete the following information):

cherepanov-max commented 3 years ago

Describe the bug I recently reinstalled all modules and the futures websocket suddenly stopped working (no exceptions thrown). Downgrading to "websockets==9.1" resolved the issue.

To Reproduce Install the latest version of python-binance and websockets, then the following code will get stuck at tscm.recv() client = await AsyncClient.create() bm = BinanceSocketManager(client) ts = bm.aggtrade_futures_socket('BTCUSDT') async with ts as tscm: while True: res = await tscm.recv() print(res)

Environment (please complete the following information):

  • Python version: 3.8.10
  • OS: [Ubuntu]
  • python-binance version: 1.0.12

I have the same problem. I have suffered losses because of this. Developers need to commit versions of dependent libraries in files requirements.txt and setup.py.

DaStapo commented 3 years ago

Yeah, took me a while to figure out what the issue even was. I forgot to mention that I only tried the aggregated trades websocket stream and that it works for spot markets while the futures markets does not.

weimingxu311 commented 3 years ago

OMG It takes me 48 hours to find the problem

weimingxu311 commented 3 years ago

Describe the bug I recently reinstalled all modules and the futures websocket suddenly stopped working (no exceptions thrown). Downgrading to "websockets==9.1" resolved the issue. To Reproduce Install the latest version of python-binance and websockets, then the following code will get stuck at tscm.recv() client = await AsyncClient.create() bm = BinanceSocketManager(client) ts = bm.aggtrade_futures_socket('BTCUSDT') async with ts as tscm: while True: res = await tscm.recv() print(res) Environment (please complete the following information):

  • Python version: 3.8.10
  • OS: [Ubuntu]
  • python-binance version: 1.0.12

I have the same problem. I have suffered losses because of this. Developers need to commit versions of dependent libraries in files requirements.txt and setup.py.

I could not agree anymore. Developers need to commit versions of dependent libraries in files requirements.txt and setup.py.

MennovDijk commented 3 years ago

Big issue indeed, recently did a reinstall and took me a long long time to figure out what's wrong...

Molloss commented 3 years ago

Still didn't work for me :(

Python version : 3.9.7 OS: Windows 10 Pro python-binance version: 1.0.14

I tried with websockets 9.1, 8.1, upgrading my python version, my python-binance version, nothing work :(

cuongitl commented 2 years ago

@DaStapo Thank you very much! It takes me 48 hours to find out what's the problem.

@Molloss: you're same env with me. If you're using testnet, you must me change code in stream.py #929

jong950715 commented 2 years ago

I tried future socket over 6~8 hours. finally I solved it thanks to you by downgrade websockets.

uzunkadir commented 2 years ago

I tried future socket over 6~8 hours. finally I solved it thanks to you by downgrade websockets.

What is the version of the websockets library at your system ? I have same problem. Every stream works except futures socket.

ericcastro commented 2 years ago

this issue is still going on, after 20 days of being reported.

manually installing websockets==9.1 continues to be the solution, while installing dependencies as-is from this library continues to be broken

oliver-zehentleitner commented 2 years ago

Here you can find information about the cause and suggestions for a workaround: https://github.com/aaugustin/websockets/issues/1065

It looks like websockets will be able to handle this again in future versions: https://github.com/aaugustin/websockets/pull/1067/files

QuanticDisaster commented 2 years ago

this issue is still going on, after 20 days of being reported.

manually installing websockets==9.1 continues to be the solution, while installing dependencies as-is from this library continues to be broken

@ericcastro I have the same problem, but websockets version 9.1 does not seem to work for me, does this snippet work for you ?

from binance import ThreadedWebsocketManager
bsm = ThreadedWebsocketManager()
bsm.start()
def show_ticker(msg):
    print(msg)

bsm.start_kline_futures_socket(callback=show_ticker, symbol='BTCUSDT', interval='1m')
dvdblk commented 2 years ago

websockets==9.1 gets installed by default now with this library however I still can't see any streams with multiplex.

Wat do?

firat911 commented 10 months ago

Hello, add this at the start of your code:

import asyncio
import nest_asyncio
nest_asyncio.apply()

that should be enough