LUCIT-Systems-and-Development / unicorn-binance-websocket-api

A Python SDK by LUCIT to use the Binance Websocket API`s (com+testnet, com-margin+testnet, com-isolated_margin+testnet, com-futures+testnet, com-coin_futures, us, tr, dex/chain+testnet) in a simple, fast, flexible, robust and fully-featured way.
https://unicorn-binance-websocket-api.docs.lucit.tech/
Other
680 stars 165 forks source link

Websocket error on testnet for userdata stream #143

Closed GauthamramRavichandran closed 3 years ago

GauthamramRavichandran commented 3 years ago

Select one:

Environment

What kind of internet connection do you have?

Broadband with >80Mbps network speed

Operating System? (include version)

Options

Which endpoint do you connect?

binance.org-testnet

Python Version Requirement

Exact Python Version?

python 3.8.5

Pip Version?

20.0.1

Dependencies

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

UNICORN Binance WebSocket API Version?

Installed the latest version,

Description of your issue

Got this error, AttributeError: 'BinanceWebSocketApiRestclient' object has no attribute 'path_userdata'

I tried this example with only one stream in testnet exchange "binance.org-testnet"

GauthamramRavichandran commented 3 years ago

Any progress?

oliver-zehentleitner commented 3 years ago

Could you please provide the full error trace?

GauthamramRavichandran commented 3 years ago

I don't have access to the desktop (one mentioned in issue desc.)

Below traceback is from this config: OS: MacOS Big Sur Arch: M1 Python: 3.9.1 pip: 20.3.3 unicorn-binance-websocket-api: 1.28.0

Exception in thread Thread-4:
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/opt/homebrew/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/gauthamramravichandran/PycharmProjects/sample-proj/env/lib/python3.9/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_manager.py", line 433, in _create_stream_thread
    loop.run_until_complete(socket.start_socket())
  File "/opt/homebrew/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/Users/gauthamramravichandran/PycharmProjects/sample-proj/env/lib/python3.9/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_socket.py", line 63, in start_socket
    async with BinanceWebSocketApiConnection(self.manager,
  File "/Users/gauthamramravichandran/PycharmProjects/sample-proj/env/lib/python3.9/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_connection.py", line 72, in __aenter__
    uri = self.manager.create_websocket_uri(self.channels,
  File "/Users/gauthamramravichandran/PycharmProjects/sample-proj/env/lib/python3.9/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_manager.py", line 1167, in create_websocket_uri
    response = self.get_listen_key_from_restclient(stream_id, api_key, api_secret, symbols=symbols)
  File "/Users/gauthamramravichandran/PycharmProjects/sample-proj/env/lib/python3.9/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_manager.py", line 1690, in get_listen_key_from_restclient
    response = self.restclient.get_listen_key(stream_id)
  File "/Users/gauthamramravichandran/PycharmProjects/sample-proj/env/lib/python3.9/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_restclient.py", line 282, in get_listen_key
    response = self._request(method, self.path_userdata)
AttributeError: 'BinanceWebSocketApiRestclient' object has no attribute 'path_userdata'
====================== unicorn-binance-websocket-api_1.28.0-python_3.9.1 ======================
 exchange: binance.org-testnet
 uptime: 2 seconds since 2021-02-02, 15:53:52 UTC
 streams: 1
 subscriptions: 0
 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-02-02, 15:53:52 UTC)
 total_receives: 0
 total_received_bytes: 0 (0 B)
 total_transmitted_payloads: 0
 process_ressource_usage: cpu=0.0%, memory=42.59 mB, threads=4
 ---------------------------------------------------------------------------------------------
               stream_id              |   stream_label  |  last  |  average  |  most  | recon
 ---------------------------------------------------------------------------------------------
 32ecad7e-9381-4534-9160-b3583cf43966 | Alice           |      0 |       0.0 |      0 |      0 
 ---------------------------------------------------------------------------------------------
 all_streams                                            |      0 |       0.0 |      0 |      0 
===============================================================================================

Websocket continues to print these stats anyway, so web socket is working (I guess), haven't tested that yet

oliver-zehentleitner commented 3 years ago

hm, binance dex has an other syntax then cex user data streams.

look here and try again please: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/blob/d5af8999b965e20037a322253478efb0133a0aa3/example_binance_dex.py#L79

I will try to make a better exception handling