saf*_*azi 2 python proxy websocket
我正在尝试将代理与 websocket 模块中包含的 python WebSocketApp 一起使用。然而,每当我使用这段代码时,
ws=websocket.WebSocketApp('ws://echo.websocket.org:443')
ws.run_forever(http_proxy_host='my proxy here',http_proxy_port=80, # 80 is the proxy port
on_close=on_close)
Run Code Online (Sandbox Code Playgroud)
我在控制台中得到这个,然后套接字关闭
Connecting proxy...
--- request header ---
CONNECT echo.websocket.org:443 HTTP/1.0
-----------------------
--- response header ---
## SOCKET CLOSED ##
Run Code Online (Sandbox Code Playgroud)
请帮助?
如果您想要安全连接,请在 URI 中使用 的方案wss来代替。ws默认端口为 443,因此指定端口是可选的。尝试这个:
websocket.enableTrace(True)
ws=websocket.WebSocketApp('wss://echo.websocket.org') # N.B. use secure socket
ws.run_forever(http_proxy_host='my proxy here', http_proxy_port=80, on_close=on_close)
Run Code Online (Sandbox Code Playgroud)
失败的原因是远程服务器正在关闭连接,因为您正在服务器上的安全端口上进行连接,但没有在客户端上使用安全连接。
| 归档时间: |
|
| 查看次数: |
5790 次 |
| 最近记录: |