should a client initiating a disconnection from a server also trigger that client's disconnect event handler? #1347
Unanswered
arnodunstatter
asked this question in
Q&A
Replies: 1 comment 1 reply
-
You are not doing anything wrong. There is a bug in the older releases of python-socketio. This issue was fixed in release 5.1.0, you can see it referenced in the release notes for that release. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I noticed that when my client calls its
.connect()
method it also has its connect event handler triggered, and in the documentation for v4 (I'm using 4.6.1) it says "The connect, connect_error and disconnect events are special; they are invoked automatically when a client connects or disconnects from the server:" & "The disconnect handler is invoked for application initiated disconnects, server initiated disconnects, or accidental disconnects". That said, when my client calls its.disconnect()
method I do not see the printout from my client's disconnection handler as I would expect.To try and figure out if this was arising out of the fact that the server code is written in javascript by other developers (i.e. it's a complex system) I tried to simulate a simplified version of the connection by running a pure python-socketio client-server connection simulation by using videos 1 and 10 from your youtube python-socketio tutorial playlist (great videos by the way, very helpful). There again, when my client disconnects it does not have its own disconnect event handler triggered.
I further noticed that if I reinstall python-socketio without specifying my version such that the most up to date version (currently v5.11.2) is installed, then I see what I expect from the documentation: when my client disconnects it's disconnection event handler is also triggered.
When I look at the source code for the JavaScript socket.js implementation for the version compatible with 4.6.1, its
Socket.prototype.onpacket
function'scase parser.DISCONNECT:
(what I believe handles incoming disconnect events) callsthis.ondisconnect()
which in turn callsthis.onclose('client namespace disconnect')
which then appears to emit both a'disconnecting'
and'disconnect'
event, again making me suspect that my client's disconnect event handler should be getting triggered when it calls its.disconnect()
method.Any ideas what I could be doing wrong?

Beta Was this translation helpful? Give feedback.
All reactions