websocket-client:通过代理状态CONNECT失败:503

时间:2018-02-22 05:27:01

标签: python websocket

我正在测试基本代码,它正在运行,因为它应该

import websocket 

ws = websocket.WebSocket()
ws.connect("wss://echo.websocket.org/")
send_string = "Testing WebSocket"
print "Sending: ",send_string
ws.send(send_string)
result = ws.recv()
print "Received: ",result
ws.close()

但是在将websocket地址更改为我的愿望之后“wss://10.240.118.148:51443 / ws /”我有:

Traceback (most recent call last):
  File "testws.py", line 5, in <module>
    ws.connect("wss://10.240.118.148:51443/ws/")
  File "/usr/lib/python2.7/site-packages/websocket/_core.py", line 213, in connect
    options.pop('socket', None))
  File "/usr/lib/python2.7/site-packages/websocket/_http.py", line 72, in connect
    sock = _tunnel(sock, hostname, port, auth)
  File "/usr/lib/python2.7/site-packages/websocket/_http.py", line 224, in _tunnel
    "failed CONNECT via proxy status: %r" % status)
websocket._exceptions.WebSocketProxyException: failed CONNECT via proxy status: 503

当然,与websocket的连接正在发挥作用:

wscat -n -c wss://10.240.118.148:51443/ws/

connected (press CTRL+C to quit)
> test

< {"error":{"code":-32700,"data":"parse error - unexpected 't'","message":"Parse error"},"id":null,"jsonrpc":"2.0"}

你知道什么是错的吗?

1 个答案:

答案 0 :(得分:0)

“通过代理状态CONNECT失败:503”确实是服务器错误,而不是代理错误,您必须查询服务器的错误日志文件以找出问题的原因。