[英]Python websocket-client WebSocketApp proxy not connecting?
I'm trying to use proxies with a python WebSocketApp included in the websocket module. 我正在尝试将代理与websocket模块中包含的python WebSocketApp一起使用。 However, whenever I use this code,
但是,每当我使用此代码时,
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)
I get this in the console, and then the socket closes 我在控制台中得到它,然后套接字关闭
Connecting proxy...
--- request header ---
CONNECT echo.websocket.org:443 HTTP/1.0
-----------------------
--- response header ---
## SOCKET CLOSED ##
Help please? 请帮助?
If you want a secure connection use a scheme of wss
instead of ws
in the URI. 如果要安全连接,请在URL中使用
wss
而不是ws
的方案。 The default port is 443, so specifying the port is optional. 默认端口是443,因此指定端口是可选的。 Try this:
尝试这个:
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)
The reason that it was failing is that the remote server is closing the connection because you were connecting on a secure port on the server, but not using a secure connection on the client. 失败的原因是远程服务器正在关闭连接,因为您正在服务器上的安全端口上进行连接,但未在客户端上使用安全连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.