pythonbinancebinance-api-client

Binance Websocket API stuck on OPEN MESSAGE


I have this...

import websocket

SOCKET = "wss://stream.binance.com:9443/ws/ADABUSB@nav_kline_1m"

def on_open(ws):
    print('opened connection')

def on_close(ws):
    print('close connection')

def on_message(ws, message):
    print('received message')
    print(message)

ws = websocket.WebSocketApp(SOCKET, on_open = on_open, on_close = on_close, on_message = on_message)
ws.run_forever()

When I run it it sticks on OPENED CONNECTION and then does nothing?? Any ideas?

No error messages and I have left it for minutes!!

Cheers Zak


Solution

  • Found this and it worked! I am on a Mac...

    Spot on! removed ::1 from /etc/hosts and its connecting. localhost was resolving to ::1. Thanks for help.