Skip to content

Upgrade to 1.34.0 (and websockets 10) sockets connect, but no data received #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 of 13 tasks
jlixfeld opened this issue Sep 21, 2021 · 14 comments
Closed
5 of 13 tasks
Assignees
Labels
bug Something isn't working

Comments

@jlixfeld
Copy link

jlixfeld commented Sep 21, 2021

Check this or we will delete your issue. (fill in the checkbox with an X like so: [x])

  • I have searched for other issues with the same problem or similar feature requests.

#196 is very loosely related.

Select one:

  • Bug
  • Feature Request
  • Technical Help
  • Other

Environment

  • Are you using the module on a VPS or other Cloud hosting?
  • Are you using the module on a Raspberry Pi?

What kind of internet connection do you have?

Cable 100U/500D

Average system load (CPU)

8 core, 4% user, 5% system

Hardware specification

MacBook Pro 17" 

Operating System? (include version)

  • macOS 11.6
  • Windows
  • Linux (include flavour)

Options

  • stream_buffer
  • process_stream_data

Which endpoint do you connect?

binance.com-futures

Python Version Requirement

  • I am using Python 3.7 or above

Exact Python Version?

(binance.venv) jlixfeld@BlackBox binance % python --version
Python 3.8.9
(binance.venv) jlixfeld@BlackBox binance % python3 --version
Python 3.8.9
(binance.venv) jlixfeld@BlackBox binance % 

Pip Version?

(binance.venv) jlixfeld@BlackBox binance % pip3 --version
pip 21.2.4 from /Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/pip (python 3.8)
(binance.venv) jlixfeld@BlackBox binance % 

Dependencies

Run pip list > pip_list.txt and upload the file.

list.txt

UNICORN Binance WebSocket API Version?

(binance.venv) jlixfeld@BlackBox binance % python ./get_used_module_version.py 
1.34.0
(binance.venv) jlixfeld@BlackBox binance % 

Description of your issue

1.34.0 does not receive data while using websockets 10. Downgrading to websockets 9.1 works fine.

Attaching first 500 lines of debugs for sockets 9.1 and sockets 10.0 run.

ws10.txt
ws91.txt

Websockets 10:
In [4]: vars.ubwam.print_summary()
====================== unicorn-binance-websocket-api_1.34.0-python_3.8.9 ======================
 exchange: binance.com-futures
 uptime: 4m:25s since 2021-09-21, 12:13:45 UTC
 streams: 8
 active_streams: 8
 subscriptions: 8
 current_receiving_speed: 0 B/s
 average_receiving_speed: 0.0 B/s (per day 0.0 gB)
 highest_receiving_speed: 0 B/s (reached at 2021-09-21, 12:13:45 UTC)
 total_receives: 0
 total_received_bytes: 0 (0 B)
 total_transmitted_payloads: 7
 stream_buffer_maxlen: None
 process_ressource_usage: cpu=4.9%, memory=90.48 mB, threads=29
 ---------------------------------------------------------------------------------------------
               stream_id              |   stream_label  |  last  |  average  |  peak  | recon
 ---------------------------------------------------------------------------------------------
 d05fa829-8486-4ec1-9ec7-fcce3a0ac908 | kline_1m        |      0 |       0.0 |      0 |      0 
 6516a09a-f889-4260-bfc6-9840cccbb1d6 | kline_3m        |      0 |       0.0 |      0 |      0 
 e174ee3e-e7eb-4265-b6ef-4d3b047e1860 | kline_5m        |      0 |       0.0 |      0 |      0 
 37f4c5d5-458c-470a-8ddb-fecb33444c3a | kline_15m       |      0 |       0.0 |      0 |      0 
 e79dca7d-9ba6-40f2-9af1-2736f94e7a85 | kline_30m       |      0 |       0.0 |      0 |      0 
 f430889a-3517-414f-b228-dd352271c9d1 | kline_1h        |      0 |       0.0 |      0 |      0 
 45d8780d-5704-432d-beea-bd6306aea425 | ticker          |      0 |       0.0 |      0 |      0 
 55e123cd-d0c6-49dc-a740-83dcc436c6a2 | userdata        |      0 |       0.0 |      0 |      0 
 ---------------------------------------------------------------------------------------------
 all_streams                                            |      0 |       0.0 |      0 |      0 
===============================================================================================


In [5]:
Downgrade to websockets 9.1:

Downgrade output provided, as well as print_summary() to illustrate input after downgrade.

(binance.venv) jlixfeld@BlackBox binance % pip uninstall websockets
Found existing installation: websockets 10.0
Uninstalling websockets-10.0:
  Would remove:
    /Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets-10.0.dist-info/*
    /Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/*
  Would not remove (outside of prefix):
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/__init__.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/__main__.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/auth.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/client.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/connection.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/datastructures.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/exceptions.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/extensions/__init__.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/extensions/base.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/extensions/permessage_deflate.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/frames.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/headers.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/http.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/http11.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/imports.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/legacy/__init__.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/legacy/auth.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/legacy/client.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/legacy/compatibility.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/legacy/framing.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/legacy/handshake.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/legacy/http.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/legacy/protocol.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/legacy/server.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/server.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/streams.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/typing.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/uri.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/utils.cpython-38.pyc
    /Users/jlixfeld/Library/Caches/com.apple.python/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/websockets/version.cpython-38.pyc
Proceed (Y/n)? 
  Successfully uninstalled websockets-10.0
(binance.venv) jlixfeld@BlackBox binance % pip install websockets==9.1                                                                                                                          
Collecting websockets==9.1
  Using cached websockets-9.1-cp38-cp38-macosx_10_9_x86_64.whl (88 kB)
Installing collected packages: websockets
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
unicorn-binance-websocket-api 1.34.0 requires websockets==10.0, but you have websockets 9.1 which is incompatible.
Successfully installed websockets-9.1
(binance.venv) jlixfeld@BlackBox binance % 

In [1]: vars.ubwam.print_summary()
====================== unicorn-binance-websocket-api_1.34.0-python_3.8.9 ======================
 exchange: binance.com-futures
 uptime: 9 seconds since 2021-09-21, 12:20:47 UTC
 streams: 8
 active_streams: 8
 subscriptions: 8
 current_receiving_speed: 7.5 kB/s
 average_receiving_speed: 3.87 kB/s (per day 0.32 gB)
 highest_receiving_speed: 9.49 kB/s (reached at 2021-09-21, 12:20:53 UTC)
 total_receives: 104
 total_received_bytes: 37771 (36.89 kB)
 total_transmitted_payloads: 7
 stream_buffer_maxlen: None
 process_ressource_usage: cpu=16.0%, memory=91.69 mB, threads=29
 ---------------------------------------------------------------------------------------------
               stream_id              |   stream_label  |  last  |  average  |  peak  | recon
 ---------------------------------------------------------------------------------------------
 12d9eeea-6b03-4bf0-9f0a-771f2c74b383 | kline_1m        |      3 |       2.8 |      5 |      0 
 16cb87f0-ab12-47f3-bcc9-533224959672 | kline_3m        |      3 |       2.8 |      5 |      0 
 1a7db9ae-b329-49fe-a3c7-f315b1c8b510 | kline_5m        |      3 |       2.8 |      5 |      0 
 5834fcb0-6bb5-45b3-9d29-2db467d01270 | kline_15m       |      3 |      2.62 |      4 |      0 
 b4e3eed5-66fc-48a2-9857-d364609779a1 | kline_30m       |      3 |       2.8 |      5 |      0 
 2a7873ae-8898-4fb0-9016-c995bfbf24ee | kline_1h        |      3 |      2.63 |      4 |      0 
 55fc04ee-9233-4d36-abe5-1f2527fa8e5a | ticker          |      2 |      1.75 |      3 |      0 
 7a21cc3a-d3ea-4990-abd9-611c9df9eac0 | userdata        |      0 |       0.0 |      0 |      0 
 ---------------------------------------------------------------------------------------------
 all_streams                                            |     20 |      18.2 |     31 |      0 
===============================================================================================


In [2]:
@jlixfeld jlixfeld added the bug Something isn't working label Sep 21, 2021
@oliver-zehentleitner
Copy link
Member

Thanks for the well prepared issue!

I use websockets 10 with ubwa 1.34.0 on linux and it works fine..

Also https://www.lucit-development.co/unicorn-binance-websocket-api.html is running 1.34 with websockets 10 on a Debian system with Python 3.8.0...

python-binance has similar issues....

Can we determin if this is a macos thing?

@oliver-zehentleitner
Copy link
Member

oliver-zehentleitner commented Sep 21, 2021

As mentioned in this issue and also in
#196
sammchardy/python-binance#1023

It seems to be related to future endpoints only?

@jlixfeld
Copy link
Author

I only use Futures, so I'm not sure if it's also related to other markets.

@jlixfeld
Copy link
Author

I use websockets 10 with ubwa 1.34.0 on linux and it works fine..

Also https://www.lucit-development.co/unicorn-binance-websocket-api.html is running 1.34 with websockets 10 on a Debian system with Python 3.8.0...

Both these mentioned systems use Ubuntu? #196 references Debian and Windows 10 having the same issue.

@oliver-zehentleitner
Copy link
Member

thanks for the tips. the commonality seems to be futures endpoint.

please try on of the examples for spot and report if they works in your setup where futures doesnt work: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api#examples

@jlixfeld
Copy link
Author

thanks for the tips. the commonality seems to be futures endpoint.

Oh, I see. So your system are not using Futures then?

please try on of the examples for spot and report if they works in your setup where futures doesn't work: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api#examples

It seems limited to futures. Spot seems to work just fine:

exchange="binance.com"

(binance.venv) jlixfeld@BlackBox binance % /Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/bin/python /Users/jlixfeld/Documents/Development/crypto/binance/ws10_test.py
sb-len: 4
sb-len: 4
sb-len: 6
sb-len: 6
clearing...
sb-len: 0
sb-len: 0
sb-len: 2
sb-len: 2
sb-len: 2
sb-len: 4
sb-len: 4
sb-len: 6
sb-len: 6
sb-len: 6
sb-len: 6
sb-len: 8
sb-len: 8
sb-len: 8
sb-len: 8
sb-len: 8
sb-len: 8
sb-len: 8
sb-len: 8
sb-len: 8
sb-len: 8
sb-len: 8
sb-len: 8
FIFO START ##################################################
FIFO: {'stream_type': 'bnbbtc@kline_1m', 'event_type': 'kline', 'event_time': 1632241519760, 'symbol': 'BNBBTC', 'kline': {'kline_start_time': 1632241500000, 'kline_close_time': 1632241559999, 'symbol': 'BNBBTC', 'interval': '1m', 'first_trade_id': False, 'last_trade_id': False, 'open_price': '0.00856300', 'close_price': '0.00856600', 'high_price': '0.00856600', 'low_price': '0.00855900', 'base_volume': '27.05200000', 'number_of_trades': 24, 'is_closed': False, 'quote': '0.23160332', 'taker_by_base_asset_volume': '14.99300000', 'taker_by_quote_asset_volume': '0.12838085', 'ignore': '0'}, 'unicorn_fied': ['binance.com', '0.11.0']}
FIFO: {'stream_type': 'bnbbtc@kline_1m', 'event_type': 'kline', 'event_time': 1632241522776, 'symbol': 'BNBBTC', 'kline': {'kline_start_time': 1632241500000, 'kline_close_time': 1632241559999, 'symbol': 'BNBBTC', 'interval': '1m', 'first_trade_id': False, 'last_trade_id': False, 'open_price': '0.00856300', 'close_price': '0.00856500', 'high_price': '0.00856600', 'low_price': '0.00855900', 'base_volume': '28.15600000', 'number_of_trades': 25, 'is_closed': False, 'quote': '0.24105908', 'taker_by_base_asset_volume': '14.99300000', 'taker_by_quote_asset_volume': '0.12838085', 'ignore': '0'}, 'unicorn_fied': ['binance.com', '0.11.0']}
FIFO: {'stream_type': 'bnbbtc@kline_1m', 'event_type': 'kline', 'event_time': 1632241525778, 'symbol': 'BNBBTC', 'kline': {'kline_start_time': 1632241500000, 'kline_close_time': 1632241559999, 'symbol': 'BNBBTC', 'interval': '1m', 'first_trade_id': False, 'last_trade_id': False, 'open_price': '0.00856300', 'close_price': '0.00856600', 'high_price': '0.00856600', 'low_price': '0.00855900', 'base_volume': '28.19600000', 'number_of_trades': 26, 'is_closed': False, 'quote': '0.24140172', 'taker_by_base_asset_volume': '15.03300000', 'taker_by_quote_asset_volume': '0.12872349', 'ignore': '0'}, 'unicorn_fied': ['binance.com', '0.11.0']}
FIFO: {'stream_type': 'bnbbtc@kline_1m', 'event_type': 'kline', 'event_time': 1632241528780, 'symbol': 'BNBBTC', 'kline': {'kline_start_time': 1632241500000, 'kline_close_time': 1632241559999, 'symbol': 'BNBBTC', 'interval': '1m', 'first_trade_id': False, 'last_trade_id': False, 'open_price': '0.00856300', 'close_price': '0.00856500', 'high_price': '0.00856600', 'low_price': '0.00855900', 'base_volume': '32.40500000', 'number_of_trades': 29, 'is_closed': False, 'quote': '0.27745180', 'taker_by_base_asset_volume': '15.03300000', 'taker_by_quote_asset_volume': '0.12872349', 'ignore': '0'}, 'unicorn_fied': ['binance.com', '0.11.0']}
LIFO START ##################################################
LIFO: {'stream_type': 'bnbbtc@kline_1m', 'event_type': 'kline', 'event_time': 1632241528780, 'symbol': 'BNBBTC', 'kline': {'kline_start_time': 1632241500000, 'kline_close_time': 1632241559999, 'symbol': 'BNBBTC', 'interval': '1m', 'first_trade_id': False, 'last_trade_id': False, 'open_price': '0.00856300', 'close_price': '0.00856500', 'high_price': '0.00856600', 'low_price': '0.00855900', 'base_volume': '32.40500000', 'number_of_trades': 29, 'is_closed': False, 'quote': '0.27745180', 'taker_by_base_asset_volume': '15.03300000', 'taker_by_quote_asset_volume': '0.12872349', 'ignore': '0'}, 'unicorn_fied': ['binance.com', '0.11.0']}
LIFO: {'stream_type': 'bnbbtc@kline_1m', 'event_type': 'kline', 'event_time': 1632241525778, 'symbol': 'BNBBTC', 'kline': {'kline_start_time': 1632241500000, 'kline_close_time': 1632241559999, 'symbol': 'BNBBTC', 'interval': '1m', 'first_trade_id': False, 'last_trade_id': False, 'open_price': '0.00856300', 'close_price': '0.00856600', 'high_price': '0.00856600', 'low_price': '0.00855900', 'base_volume': '28.19600000', 'number_of_trades': 26, 'is_closed': False, 'quote': '0.24140172', 'taker_by_base_asset_volume': '15.03300000', 'taker_by_quote_asset_volume': '0.12872349', 'ignore': '0'}, 'unicorn_fied': ['binance.com', '0.11.0']}
LIFO: {'stream_type': 'bnbbtc@kline_1m', 'event_type': 'kline', 'event_time': 1632241522776, 'symbol': 'BNBBTC', 'kline': {'kline_start_time': 1632241500000, 'kline_close_time': 1632241559999, 'symbol': 'BNBBTC', 'interval': '1m', 'first_trade_id': False, 'last_trade_id': False, 'open_price': '0.00856300', 'close_price': '0.00856500', 'high_price': '0.00856600', 'low_price': '0.00855900', 'base_volume': '28.15600000', 'number_of_trades': 25, 'is_closed': False, 'quote': '0.24105908', 'taker_by_base_asset_volume': '14.99300000', 'taker_by_quote_asset_volume': '0.12838085', 'ignore': '0'}, 'unicorn_fied': ['binance.com', '0.11.0']}
LIFO: {'stream_type': 'bnbbtc@kline_1m', 'event_type': 'kline', 'event_time': 1632241519760, 'symbol': 'BNBBTC', 'kline': {'kline_start_time': 1632241500000, 'kline_close_time': 1632241559999, 'symbol': 'BNBBTC', 'interval': '1m', 'first_trade_id': False, 'last_trade_id': False, 'open_price': '0.00856300', 'close_price': '0.00856600', 'high_price': '0.00856600', 'low_price': '0.00855900', 'base_volume': '27.05200000', 'number_of_trades': 24, 'is_closed': False, 'quote': '0.23160332', 'taker_by_base_asset_volume': '14.99300000', 'taker_by_quote_asset_volume': '0.12838085', 'ignore': '0'}, 'unicorn_fied': ['binance.com', '0.11.0']}
(binance.venv) jlixfeld@BlackBox binance % 

exchange="binance.com-futures"

(binance.venv) jlixfeld@BlackBox binance % /Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/bin/python /Users/jlixfeld/Documents/Development/crypto/binance/ws10_test.py
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
clearing...
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
sb-len: 0
FIFO START ##################################################
LIFO START ##################################################
^CException ignored in: <module 'threading' from '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/threading.py'>
Traceback (most recent call last):
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/threading.py", line 1388, in _shutdown
    lock.acquire()
KeyboardInterrupt: 
(binance.venv) jlixfeld@BlackBox binance % 

@oliver-zehentleitner
Copy link
Member

Made the same test.... everything works except futures...

@June911
Copy link

June911 commented Sep 22, 2021

Made the same test.... everything works except futures...

yess. everything works except futures...

#196 That's what I was trying to say in the post.

@oliver-zehentleitner
Copy link
Member

I think a good next step is to analyse websocket headers of a working and non working endpoint and look for differences. i am busy this week ....

@oliver-zehentleitner
Copy link
Member

@June911 Sorry, I overlooked that this only concerns futures.

@oliver-zehentleitner
Copy link
Member

oliver-zehentleitner commented Oct 2, 2021

Test with websockets 10.0

binance.com-futures: NOT WORKING

2021-10-02 15:03:01,094 [INFO    ] 7641 140385384228672 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.create_stream(['arr'], ['!miniTicker'], None, False, False) with stream_id=90da3518-4325-4418-994c-cde5bdf01030
2021-10-02 15:03:01,094 [INFO    ] 7641 140385384228672 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager._add_stream_to_stream_list(90da3518-4325-4418-994c-cde5bdf01030, ['arr'], ['!miniTicker'], None, False, None, False)
2021-10-02 15:03:01,095 [DEBUG   ] 7641 140385384228672 selector_events: Using selector: EpollSelector
2021-10-02 15:03:01,096 [DEBUG   ] 7641 140385329067776 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.is_stop_request(90da3518-4325-4418-994c-cde5bdf01030)
2021-10-02 15:03:01,097 [INFO    ] 7641 140385329067776 unicorn_binance_websocket_api_socket: BinanceWebSocketApiSocket.start_socket(90da3518-4325-4418-994c-cde5bdf01030, ['arr'], ['!miniTicker']) socket_id=b1ffbb95-6aa3-4a91-a722-e03bc266bcab recent_socket_id=b1ffbb95-6aa3-4a91-a722-e03bc266bcab
2021-10-02 15:03:01,098 [DEBUG   ] 7641 140385329067776 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.is_stop_request(90da3518-4325-4418-994c-cde5bdf01030)
2021-10-02 15:03:02,213 [DEBUG   ] 7641 140385329067776 protocol: = connection is CONNECTING
2021-10-02 15:03:02,861 [DEBUG   ] 7641 140385329067776 client: > GET /ws/!miniTicker@arr HTTP/1.1
2021-10-02 15:03:02,861 [DEBUG   ] 7641 140385329067776 client: > Host: fstream.binance.com
2021-10-02 15:03:02,862 [DEBUG   ] 7641 140385329067776 client: > Upgrade: websocket
2021-10-02 15:03:02,862 [DEBUG   ] 7641 140385329067776 client: > Connection: Upgrade
2021-10-02 15:03:02,862 [DEBUG   ] 7641 140385329067776 client: > Sec-WebSocket-Key: hS/mWmODJb11AAMRx6D3Qg==
2021-10-02 15:03:02,862 [DEBUG   ] 7641 140385329067776 client: > Sec-WebSocket-Version: 13
2021-10-02 15:03:02,862 [DEBUG   ] 7641 140385329067776 client: > Sec-WebSocket-Extensions: permessage-deflate; server_max_window_bits=12; client_max_window_bits=12
2021-10-02 15:03:02,863 [DEBUG   ] 7641 140385329067776 client: > User-Agent: unicorn-binance-websocket-api_1.34.0.dev-python_3.8.10
2021-10-02 15:03:03,168 [DEBUG   ] 7641 140385329067776 client: < HTTP/1.1 101 Switching Protocols
2021-10-02 15:03:03,168 [DEBUG   ] 7641 140385329067776 client: < Date: Sat, 02 Oct 2021 13:03:02 GMT
2021-10-02 15:03:03,168 [DEBUG   ] 7641 140385329067776 client: < Connection: upgrade
2021-10-02 15:03:03,168 [DEBUG   ] 7641 140385329067776 client: < upgrade: websocket
2021-10-02 15:03:03,169 [DEBUG   ] 7641 140385329067776 client: < sec-websocket-accept: 0z20ZrLo6SDw4UjoXP+Ep1kdimo=
2021-10-02 15:03:03,169 [DEBUG   ] 7641 140385329067776 client: < sec-websocket-extensions: permessage-deflate;server_max_window_bits=12
2021-10-02 15:03:03,169 [DEBUG   ] 7641 140385329067776 protocol: = connection is OPEN

binance.com: WORKING

2021-10-02 15:04:47,042 [INFO    ] 7685 140172700063552 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.create_stream(['arr'], ['!miniTicker'], None, False, False) with stream_id=c4f48ad8-0230-49b5-acd5-f827b59de4fd
2021-10-02 15:04:47,043 [INFO    ] 7685 140172700063552 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager._add_stream_to_stream_list(c4f48ad8-0230-49b5-acd5-f827b59de4fd, ['arr'], ['!miniTicker'], None, False, None, False)
2021-10-02 15:04:47,043 [DEBUG   ] 7685 140172700063552 selector_events: Using selector: EpollSelector
2021-10-02 15:04:47,044 [DEBUG   ] 7685 140172644902656 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.is_stop_request(c4f48ad8-0230-49b5-acd5-f827b59de4fd)
2021-10-02 15:04:47,045 [INFO    ] 7685 140172644902656 unicorn_binance_websocket_api_socket: BinanceWebSocketApiSocket.start_socket(c4f48ad8-0230-49b5-acd5-f827b59de4fd, ['arr'], ['!miniTicker']) socket_id=81efc7fc-21b6-4444-b1e7-eca6831a797a recent_socket_id=81efc7fc-21b6-4444-b1e7-eca6831a797a
2021-10-02 15:04:47,046 [DEBUG   ] 7685 140172644902656 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.is_stop_request(c4f48ad8-0230-49b5-acd5-f827b59de4fd)
2021-10-02 15:04:48,190 [DEBUG   ] 7685 140172644902656 protocol: = connection is CONNECTING
2021-10-02 15:04:48,799 [DEBUG   ] 7685 140172644902656 client: > GET /ws/!miniTicker@arr HTTP/1.1
2021-10-02 15:04:48,799 [DEBUG   ] 7685 140172644902656 client: > Host: stream.binance.com:9443
2021-10-02 15:04:48,799 [DEBUG   ] 7685 140172644902656 client: > Upgrade: websocket
2021-10-02 15:04:48,799 [DEBUG   ] 7685 140172644902656 client: > Connection: Upgrade
2021-10-02 15:04:48,800 [DEBUG   ] 7685 140172644902656 client: > Sec-WebSocket-Key: 3MrUj4rWSdQC+kYpaGWZvQ==
2021-10-02 15:04:48,800 [DEBUG   ] 7685 140172644902656 client: > Sec-WebSocket-Version: 13
2021-10-02 15:04:48,800 [DEBUG   ] 7685 140172644902656 client: > Sec-WebSocket-Extensions: permessage-deflate; server_max_window_bits=12; client_max_window_bits=12
2021-10-02 15:04:48,800 [DEBUG   ] 7685 140172644902656 client: > User-Agent: unicorn-binance-websocket-api_1.34.0.dev-python_3.8.10
2021-10-02 15:04:49,051 [DEBUG   ] 7685 140172644902656 client: < HTTP/1.1 101 Switching Protocols
2021-10-02 15:04:49,051 [DEBUG   ] 7685 140172644902656 client: < Date: Sat, 02 Oct 2021 13:04:48 GMT
2021-10-02 15:04:49,052 [DEBUG   ] 7685 140172644902656 client: < Connection: upgrade
2021-10-02 15:04:49,052 [DEBUG   ] 7685 140172644902656 client: < Upgrade: websocket
2021-10-02 15:04:49,052 [DEBUG   ] 7685 140172644902656 client: < Sec-WebSocket-Accept: 5IyJog3aJ1dOQUiYeWhtxm0IWqs=
2021-10-02 15:04:49,052 [DEBUG   ] 7685 140172644902656 client: < Sec-WebSocket-Extensions: permessage-deflate; server_no_context_takeover; server_max_window_bits=8; client_max_window_bits=12
2021-10-02 15:04:49,053 [DEBUG   ] 7685 140172644902656 protocol: = connection is OPEN

@oliver-zehentleitner
Copy link
Member

oliver-zehentleitner commented Oct 2, 2021

Test with websockets==9.1

binance.com-futures: WORKING

2021-10-02 15:17:55,038 [INFO    ] 8120 139635607369536 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.create_stream(['arr'], ['!miniTicker'], None, False, False) with stream_id=99144b96-1be0-432f-bf49-0e825cf7e39f
2021-10-02 15:17:55,038 [INFO    ] 8120 139635607369536 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager._add_stream_to_stream_list(99144b96-1be0-432f-bf49-0e825cf7e39f, ['arr'], ['!miniTicker'], None, False, None, False)
2021-10-02 15:17:55,039 [DEBUG   ] 8120 139635607369536 selector_events: Using selector: EpollSelector
2021-10-02 15:17:55,040 [DEBUG   ] 8120 139635552470784 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.is_stop_request(99144b96-1be0-432f-bf49-0e825cf7e39f)
2021-10-02 15:17:55,041 [INFO    ] 8120 139635552470784 unicorn_binance_websocket_api_socket: BinanceWebSocketApiSocket.start_socket(99144b96-1be0-432f-bf49-0e825cf7e39f, ['arr'], ['!miniTicker']) socket_id=d2c69123-6d29-4e30-bfe9-22d0cd9465b7 recent_socket_id=d2c69123-6d29-4e30-bfe9-22d0cd9465b7
2021-10-02 15:17:55,041 [DEBUG   ] 8120 139635552470784 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.is_stop_request(99144b96-1be0-432f-bf49-0e825cf7e39f)
2021-10-02 15:17:56,165 [DEBUG   ] 8120 139635552470784 protocol: client - state = CONNECTING
2021-10-02 15:17:56,784 [DEBUG   ] 8120 139635552470784 protocol: client - event = connection_made(<asyncio.sslproto._SSLProtocolTransport object at 0x7eff6dfd0ca0>)
2021-10-02 15:17:56,786 [DEBUG   ] 8120 139635552470784 client: client > GET /ws/!miniTicker@arr HTTP/1.1
2021-10-02 15:17:56,786 [DEBUG   ] 8120 139635552470784 client: client > Headers([('Host', 'fstream.binance.com'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'Eqedoa+6DoQKRcfn5LHsTg=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'unicorn-binance-websocket-api_1.34.0.dev-python_3.8.10')])
2021-10-02 15:17:57,086 [DEBUG   ] 8120 139635552470784 protocol: client - event = data_received(<212 bytes>)
2021-10-02 15:17:57,087 [DEBUG   ] 8120 139635552470784 client: client < HTTP/1.1 101 Switching Protocols
2021-10-02 15:17:57,087 [DEBUG   ] 8120 139635552470784 client: client < Headers([('Date', 'Sat, 02 Oct 2021 13:17:56 GMT'), ('Connection', 'upgrade'), ('upgrade', 'websocket'), ('sec-websocket-accept', '/r6+jYquJXezY1b9AMGLl2AbAJI='), ('sec-websocket-extensions', 'permessage-deflate')])
2021-10-02 15:17:57,088 [DEBUG   ] 8120 139635552470784 protocol: client - state = OPEN

binance.com: WORKING

2021-10-02 15:20:53,833 [INFO    ] 8180 140601335281472 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.create_stream(['arr'], ['!miniTicker'], None, False, False) with stream_id=e2174837-149b-4059-9a62-7f81fe03fbbe
2021-10-02 15:20:53,833 [INFO    ] 8180 140601335281472 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager._add_stream_to_stream_list(e2174837-149b-4059-9a62-7f81fe03fbbe, ['arr'], ['!miniTicker'], None, False, None, False)
2021-10-02 15:20:53,834 [DEBUG   ] 8180 140601335281472 selector_events: Using selector: EpollSelector
2021-10-02 15:20:53,835 [DEBUG   ] 8180 140601280382720 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.is_stop_request(e2174837-149b-4059-9a62-7f81fe03fbbe)
2021-10-02 15:20:53,836 [INFO    ] 8180 140601280382720 unicorn_binance_websocket_api_socket: BinanceWebSocketApiSocket.start_socket(e2174837-149b-4059-9a62-7f81fe03fbbe, ['arr'], ['!miniTicker']) socket_id=a80ec4a0-1917-4ec1-b590-f54f1d9d01cd recent_socket_id=a80ec4a0-1917-4ec1-b590-f54f1d9d01cd
2021-10-02 15:20:53,837 [DEBUG   ] 8180 140601280382720 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.is_stop_request(e2174837-149b-4059-9a62-7f81fe03fbbe)
2021-10-02 15:20:55,272 [DEBUG   ] 8180 140601280382720 protocol: client - state = CONNECTING
2021-10-02 15:20:55,885 [DEBUG   ] 8180 140601280382720 protocol: client - event = connection_made(<asyncio.sslproto._SSLProtocolTransport object at 0x7fe0485b8b20>)
2021-10-02 15:20:55,886 [DEBUG   ] 8180 140601280382720 client: client > GET /ws/!miniTicker@arr HTTP/1.1
2021-10-02 15:20:55,886 [DEBUG   ] 8180 140601280382720 client: client > Headers([('Host', 'stream.binance.com:9443'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', '6G8RdujWgfSzzwZPcn6BhA=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'unicorn-binance-websocket-api_1.34.0.dev-python_3.8.10')])
2021-10-02 15:20:56,192 [DEBUG   ] 8180 140601280382720 protocol: client - event = data_received(<267 bytes>)
2021-10-02 15:20:56,193 [DEBUG   ] 8180 140601280382720 client: client < HTTP/1.1 101 Switching Protocols
2021-10-02 15:20:56,193 [DEBUG   ] 8180 140601280382720 client: client < Headers([('Date', 'Sat, 02 Oct 2021 13:20:55 GMT'), ('Connection', 'upgrade'), ('Upgrade', 'websocket'), ('Sec-WebSocket-Accept', 'E+0FvDPOGJ2Eq3qbyYUXETz3Odw='), ('Sec-WebSocket-Extensions', 'permessage-deflate; server_no_context_takeover; client_max_window_bits=15')])
2021-10-02 15:20:56,194 [DEBUG   ] 8180 140601280382720 protocol: client - state = OPEN

@oliver-zehentleitner
Copy link
Member

@oliver-zehentleitner
Copy link
Member

Answer from Binance:

... the relevant issue was tracked down and fixed in the new build on the futures side, its currently in testing, and the production should be updated to it by the end of Oct.

And websockets lib has merged a commit for better compatibility: python-websockets/websockets#1067

So if websockets release an upgrade or if binance future endpoints are upgraded we can turn on compression for future endpoint again.

Seven-112 pushed a commit to Seven-112/unicorn-binance-websocket-api that referenced this issue May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants