-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Describe the bug
binance api 404
To Reproduce
binance_websocket_api = await AsyncClient.create(binance_api_key_return, binance_api_secret_return)
binance_bsm = BinanceSocketManager(binance_websocket_api)
async with binance_bsm.user_socket() as binance_stream:
while True:
binance_user_socket_message = await binance_stream.recv()
Expected behavior
The code has been working, but suddenly prompted API [+] [2025-10-09 15:17:51.606442] [binance_current_assets_surpuls_api] [debug] [APIError(code=0): Invalid JSON error message from Binance: <bound method ClientResponse.text of <ClientResponse(https://api.binance.com/api/v3/userDataStream) [404 Not Found]>
Environment (please complete the following information):
Python 3.11.2
Debian 12
python-binance 1.0.29
Logs
[+] [2025-10-09 15:17:51.606442] [binance_current_assets_surpuls_api] [debug] [APIError(code=0): Invalid JSON error message from Binance: <bound method ClientResponse.text of <ClientResponse(https://api.binance.com/api/v3/userDataStream) [404 Not Found]>
<CIMultiDictProxy('Content-Length': '0', 'Connection': 'keep-alive', 'Date': 'Thu, 09 Oct 2025 07:17:50 GMT', 'Expires': '0', 'Server': 'nginx', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src 'self'", 'X-Content-Security-Policy': "default-src 'self'", 'X-WebKit-CSP': "default-src 'self'", 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 c9300fee53e483fd91f18a10d4431680.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'FRA60-P12', 'X-Amz-Cf-Id': '_y_MkrSg8DTOwcfU28Kv1QBikdPkE_GSVw58UOEThciHVgm6djwxAQ==')>
]
try:
async with binance_bsm.user_socket() as binance_stream:
binance_websocket_api = await AsyncClient.create(binance_api_key_return, binance_api_secret_return)
binance_bsm = BinanceSocketManager(binance_websocket_api)
async with binance_bsm.user_socket() as binance_stream:
while True:
binance_user_socket_message = await binance_stream.recv() except Exception as binance_current_assets_surpuls_debug_return:
print(
f"[+] [{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') + '.{:05d}'.format(datetime.datetime.now().microsecond)}] "
f"[binance_current_assets_surpuls_api] [debug] "
f"[{binance_current_assets_surpuls_debug_return}]"
)
finally:
await binance_bsm.close_connection()
**Additional context**
Add any other context about the problem here.