我正在尝试连接到socket.io服务器并接收消息。但是在连接时,我得到了socketio.exceptions.ConnectionError:一个或多个名称空间连接失败
代码:
import socketio
sio = socketio.Client()
@sio.event
def connect():
print('connection established')
sio.emit('login', {'token': 'token'})
@sio.event
def my_message(data):
print('message received with ', data)
@sio.event
def disconnect():
print('disconnected from server')
sio.connect('wss://socket.boticord.top')
sio.wait()完整的错误日志:
Attempting polling connection to https://socket.boticord.top/socket.io/?transport=polling&EIO=4
Polling connection accepted with {'sid': 'JBtkTO-XTOL-OFo2AAAH', 'upgrades': ['websocket'], 'pingInterval': 25000, 'pingTimeout': 5000}
Engine.IO connection established
Sending packet MESSAGE data 0
Attempting WebSocket upgrade to wss://socket.boticord.top/socket.io/?transport=websocket&EIO=4
WebSocket upgrade failed: connection error
Sending polling GET request to https://socket.boticord.top/socket.io/?transport=polling&EIO=4&sid=JBtkTO-XTOL-OFo2AAAH
Unexpected status code 400 in server response, aborting
Waiting for write loop task to end
Sending packet CLOSE data None
Engine.IO connection dropped
Traceback (most recent call last):
File "c:\Users\Kiril\Documents\senko\bot2\senkobot\main2.py", line 6, in <module>
sio.connect('wss://socket.boticord.top')
File "C:\Users\Kiril\AppData\Local\Programs\Python\Python39\lib\site-packages\socketio\client.py", line 338, in connect
raise exceptions.ConnectionError(
socketio.exceptions.ConnectionError: One or more namespaces failed to connect
HTTP POST request to https://socket.boticord.top/socket.io/?transport=polling&EIO=4&sid=JBtkTO-XTOL-OFo2AAAH failed with error HTTPSConnectionPool(host='socket.boticord.top', port=443): Read timed out. (read timeout=5).
Connection refused by the server, aborting
Exiting write loop task
Exiting read loop task发布于 2021-09-28 08:30:12
试一试
sio.connect('wss://socket.boticord.top', wait_timeout = 10)发布于 2021-08-10 08:05:49
请尝试使用4-5.x版本的python-socketio,或联系技术支持人员。
后端开发人员的
cipherka
https://stackoverflow.com/questions/68687773
复制相似问题