首页 > 解决方案 > Python Websocket - ConnectionRefusedError:[Errno 111] 连接被拒绝

问题描述

我实际上是在尝试使用带有 localhost 连接的 websocket hello world 示例。

from websocket import create_connection
ws = create_connection("wss://localhost:5000/websocket", timeout=5)
print ("Sending 'Hello, World'...")
ws.send("Hello, World")
print ("Sent")
print ("Receiving...")
result =  ws.recv()
print ("Received '%s'" % result)
ws.close()

我得到的错误是:

ConnectionRefusedError: [Errno 111] Connection refused

提前感谢您的帮助

标签: pythonwebsocket

解决方案


推荐阅读