Cannot upgrade the client connection to websocket #1659
Unanswered
heflinstephenraj
asked this question in
Q&A
Replies: 1 comment 13 replies
-
Please don't write issues unless you know exactly what the issue is. The discussion board is the right place to troubleshoot. Have you read the documentation? In particular the section about Socket.IO client and server compatiblity? Are you using compatible versions? |
Beta Was this translation helpful? Give feedback.
13 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
I am building a chat app.
To Reproduce
requirements.txt
cffi==1.14.6
Click==7.0
colorama==0.4.4
Flask==1.0.2
Flask-Login==0.4.1
Flask-SocketIO==3.3.2
Flask-SQLAlchemy==2.5.1
Flask-WTF==0.14.2
gevent==21.1.2
gevent-websocket==0.10.1
greenlet==1.1.0
gunicorn==20.1.0
itsdangerous==1.1.0
Flask-Cors==3.0.10
Jinja2==2.11.3
MarkupSafe==1.1.1
requests==2.25.1
passlib==1.7.1
psycopg2==2.9.1
pycparser==2.20
python-engineio==3.5.1
python-socketio==3.1.2
six==1.12.0
SQLAlchemy==1.4.20
Werkzeug==0.14.1
WTForms==2.2.1
zope.event==4.5.0
zope.interface==5.4.0
Flask App
@socketio.on('incoming-msg')
def on_message(data):
"""Broadcast messages"""
print("INCOMMING MESSAGE >> ",data)
msg = data["msg"]
username = data["username"]
room = data["room"]
# Set timestamp
time = datetime.datetime.now().strftime("%I:%M %p %d %B, %Y")
send({"username": username, "msg": msg, "time_stamp": time}, room=room
@socketio.on('join')
def on_join(data):
"""User joins a room"""
print("JOIN REQUEST >> ",data)
username = data["username"]
room = data["room"]
join_room(room)
# Broadcast that new user has joined
send({"msg": username.title() + " has joined the" + f" chat."}, room=room)
@socketio.on('leave')
def on_leave(data):
"""User leaves a room"""
print(f"LEVE REQUEST >>> {data}")
username = data['username']
room = data['room']
send({"msg": username.title() + f" has left the chat."}, room=room)
leave_room(room)
Client side socketio
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.6/socket.io.min.js"></script>SocketIO logs
867b6d49dc864a98a7e241c94d7f65fc: Sending packet OPEN data {'sid': '867b6d49dc864a98a7e241c94d7f65fc', 'upgrades': ['websocket'], 'pingTimeout': 60000, 'pingInterval': 25000}
867b6d49dc864a98a7e241c94d7f65fc: Sending packet MESSAGE data 0
867b6d49dc864a98a7e241c94d7f65fc: Received packet MESSAGE data 2["join",{"username":"Stephen Support Team","room":"ticket_115"}]
received event "join" from 867b6d49dc864a98a7e241c94d7f65fc [/]
JOIN REQUEST >> {'username': 'Stephen Support Team', 'room': 'ticket_115'}
867b6d49dc864a98a7e241c94d7f65fc is entering room ticket_115 [/]
emitting event "message" to ticket_115 [/]
b90d15a8eb80464e9cd04ef6735734e4: Sending packet MESSAGE data 2["message",{"msg":"Stephen Support Team has joined the chat."}]
867b6d49dc864a98a7e241c94d7f65fc: Sending packet MESSAGE data 2["message",{"msg":"Stephen Support Team has joined the chat."}]
1017772bbc464e30a849fbbdbda53d80: Received packet PING data None
1017772bbc464e30a849fbbdbda53d80: Sending packet PONG data None
68837e4407ff4db8a93509e30691ddfb: Client is gone, closing socket
Browser console logs
websocket.js:112 WebSocket connection to 'wss://......{chat domain}.../socket.io/?EIO=3&transport=websocket&sid=867b6d49dc864a98a7e241c94d7f65fc' failed:
How to solve this?
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions