4.4.10 release makes ws connection even when raising ConnectionRefusedError
See original GitHub issueSince this is actually an separate issue, even though on the same topic, I’m creating a new issue for it.
Open browser inspector tool, go to network->ws
, and you will see a websocket connection even when you raise the ConnectionRefusedError
. It stays half-connected as you can see ping events, but aren’t able to send any messages. On trying to connect using the js client socket again after I login through http (flask-session server side setup), the client socket cannot be used to connect as it is still connected.
python
@socketio.on('connect')
def connect():
# if not current_user.is_authenticated:
raise ConnectionRefusedError()
js
import io from 'socket.io-client';
socket = io()
// this used to be hit when on python-socketio 4.3.1
socket.on('connect_error', function(error){
console.log(error)
}
// this is now hit on 4.4.1
socket.on('error', function(error){
console.log(error)
}
// on connect, disconnect ...
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Troubleshooting connection issues | Socket.IO
You are trying to reach a plain WebSocket server; The server is not reachable; The client is not compatible with the version of...
Read more >The WebSocket API (WebSockets) - Web APIs - MDN Web Docs
desktop desktop
Chrome Edge
WebSocket Full support. Chrome4. Toggle history Full support. Edge12. Toggl...
WebSocket() constructor Full support. Chrome4. Toggle history Full support. Edge12. Toggl...
Read more >Troubleshooting Connection Issues to Neo4j
When I try to use regular HTTP and port 7474 in Google Chrome, I get the "ServiceUnavailable: WebSocket connection failure" error, even though...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is actually the core of the problem I’m trying to solve. I haven’t looked specifically at the JS client yet, but yes, the idea is that the connection error should be invoked when the server declines a connection.
Right, that makes sense, thanks for the explanation.
The issue I’m having is that I don’t know where I’m supposed to handle the raised exception on the client-side (when using the JS client). Obviously the JS library isn’t your purview, but one generally hopes that the various SocketIO libs should seamlessly interoperate with each other. But when I read through the
python-socketio
client docs, I couldn’t seem to find much guidance there either for this situation.In the
python-socketio
client, is it theconnect_error()
handler that handles both thereturn False
method and theraise ConnectionRefusedError("info")
method for short-circuiting a connection? And am I right in thinking that the args inconnect_error()
are the args passed into theConnectionRefusedError
?Because when using the JS client lib, my
error
handler is triggered when Ireturn False
server-side in both4.3.x
and4.5.x
. Meanwhile, neither my client-sideerror
nor myconnect_error
handlers are being triggered when I callraise ConnectionRefusedError()
on the server side (in both mentioned versions). The JS client has “support” forconnect_error
s, it just seems like raising an exception in thepython-socketio
server isn’t doing what the JS client expects.