Example does not work
Is this code works?
Describe the bug ConnectionClosedError (received 1003 (unsupported data) binary frames are not supported; then sent 1003 (unsupported data) binary frames are not supported) BinanceWebsocketClosed (Connection closed. Reconnecting...) Traceback (most recent call last): File "C:\Users\ersint\AppData\Local\Programs\Python\Python313\Lib\asyncio\tasks.py", line 507, in wait_for return await fut ^^^^^^^^^ asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:\Users\ersint\AppData\Local\Programs\Python\Python313\Lib\site-packages\binance\ws\websocket_api.py", line 107, in request response = await asyncio.wait_for(future, timeout=self.TIMEOUT) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ersint\AppData\Local\Programs\Python\Python313\Lib\asyncio\tasks.py", line 506, in wait_for async with timeouts.timeout(timeout): ~~~~~~~~~~~~~~~~^^^^^^^^^ File "C:\Users\ersint\AppData\Local\Programs\Python\Python313\Lib\asyncio\timeouts.py", line 116, in aexit raise TimeoutError from exc_val TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "F:\pythonProject3\silsonra.py", line 28, in
To Reproduce import os import sys import asyncio
root = os.path.dirname(os.path.dirname(os.path.abspath(file))) sys.path.append(root)
from binance import AsyncClient
create order using websockets async
the API is very similar to the REST API
async def main(): api_key = "" # your api_key here secret = "" # your secret here client = AsyncClient(api_key, secret, testnet=True) order = await client.ws_create_order( symbol="LTCUSDT", side="BUY", type="MARKET", quantity=0.1, ) print(order["orderId"]) await client.close_connection()
asyncio.run(main())
Environment (please complete the following information):
- Python version: 3.13
- Virtual Env: virtualenv
- python-binance version 1.0.27
Hello @KissCoderr,
Yes locally it is working, are you sure this is not a network-related issue?
same error,my mac use proxy,but i do not know how to config ThreadedWebsocketManager, Clinet works well,, klines = self.client.get_historical_klines( symbol=Config.SYMBOL, interval=interval, start_str=start_str ) success, work on it for 1day