Currently, I experience some unexpected behavior in my websocket client for the Binance API. I get no data, but it should connect to the API and print the messages to the console.
Everything seems to be okay. Is Binance API down or so?
import websocket
# import talib
# import numpy as np
# import json
cc = 'btcusdt'
interval = '1m'
socket = f'wss://stream.binance.com:9443/ws/{cc}@kline_{interval}'
def on_close(ws):
print('close')
def on_message(ws, message):
print('message')
ws = websocket.WebSocketApp(
socket, on_message=on_message, on_close=on_close)
ws.run_forever()
When I run this script, nothing happens. I just get prompted to a new line.
Hi,
The Binance API and websocket services are operational, this is most likely a client side issue.
Could you enable tracing to help diagnose the issue further?
websocket.enableTrace(True)
Hi @tantialex ,
thx for helping me. i enabled it and here is what I get
error from callback <function on_close at 0x104e86e60>: on_close() takes 1 positional argument but 3 were given
according to the docs, on_close() takes one argument and I provided it with one argument. So, why do I get this error then?
I downgraded the version of websocket to websocket-client==0.57.0
and now I only get ‘close’. The on_message callback doesn’t result in anything.
Problem remains.
Please consult other forums for programming related issues since this is not a direct issue with the Binance API.