import websocket
def on_message(wsapp, message):
print(message)
websocket.enableTrace(True)
wsapp = websocket.WebSocketApp("wss://stream.binance.com:9443", on_message=on_message)
wsapp.run_forever()
--- request header ---
GET / HTTP/1.1
Upgrade: websocket
Host: stream.binance.com:9443
Origin: https://stream.binance.com:9443
Sec-WebSocket-Key: iYMWWVWZ0B95xfyGU+pnnQ==
Sec-WebSocket-Version: 13
Connection: Upgrade
-----------------------
--- response header ---
HTTP/1.1 404 Not Found
Date: Sun, 03 Mar 2024 15:27:45 GMT
Content-Type: text/plain
Content-Length: 20
Connection: keep-alive
-----------------------
Handshake status 404 Not Found -+-+- {'date': 'Sun, 03 Mar 2024 15:27:45 GMT', 'content-type': 'text/plain', 'content-length': '20', 'connection': 'keep-alive'} -+-+- b'Invalid request path' - goodbye