python-binance icon indicating copy to clipboard operation
python-binance copied to clipboard

Futures socket does not work with websockets version 10.0

Open DaStapo opened this issue 3 years ago • 14 comments

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

DaStapo avatar Sep 13 '21 06:09 DaStapo

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.

cherepanov-max avatar Sep 13 '21 16:09 cherepanov-max

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.

DaStapo avatar Sep 13 '21 17:09 DaStapo

OMG It takes me 48 hours to find the problem

weimingxu311 avatar Sep 14 '21 20:09 weimingxu311

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.

weimingxu311 avatar Sep 14 '21 20:09 weimingxu311

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

MennovDijk avatar Sep 14 '21 23:09 MennovDijk

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

Molloss avatar Sep 16 '21 09:09 Molloss

@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

cuongitl avatar Sep 17 '21 07:09 cuongitl

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

jong950715 avatar Sep 21 '21 09:09 jong950715

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.

uzunkadir avatar Sep 24 '21 21:09 uzunkadir

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 avatar Oct 03 '21 11:10 ericcastro

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

oliver-zehentleitner avatar Oct 11 '21 06:10 oliver-zehentleitner

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

QuanticDisaster avatar Nov 02 '21 21:11 QuanticDisaster

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

Wat do?

dvdblk avatar Dec 22 '21 21:12 dvdblk

Hello, add this at the start of your code:

import asyncio
import nest_asyncio
nest_asyncio.apply()

that should be enough

firat911 avatar Nov 11 '23 15:11 firat911