我正在将websocket-client库用于python
这是我用来打开websocket的代码。我在标题中发送子协议和令牌
UIPresentationController
这是请求
if __name__ == '__main__':
websocket.enableTrace(True)
ws = websocket.WebSocketApp(
'wss://sample url',
on_open=on_open,
on_message=on_message,
on_error=on_error,
on_close=on_close,
header=['1.0', ws_token]
)
ws.on_open = on_open
ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
我得到的答复是
--- request header ---
GET /api/action-ws/1.0/ HTTP/1.1
Upgrade: websocket
Host: ec2-63-33-203-84.eu-west-1.compute.amazonaws.com:8443
Origin: http://ec2-63-33-203-84.eu-west-1.compute.amazonaws.com:8443
Sec-WebSocket-Key: 5btowNAZfan8qrT52bMqQw==
Sec-WebSocket-Version: 13
Connection: upgrade
1.0
<token>
所以基本上,连接是打开的,然后在收到消息后关闭。
我尝试在所有地方搜索答案,但找不到。任何帮助将不胜感激。