Closed valerykustov closed 1 year ago
Thanks for the abundant details, made it much easier to locate and fix the bug!
Would you be able to install Flask-SocketIO's main branch and confirm the fix?
Wow, that was fast! It works with Flask-SocketIO-5.3.2.dev0 now.
Thank you a lot!
5.3.2 is now out with this fix. Thanks!
Description:
I have two clients connected to a flask-socketio server. When the first one emits a message the server handles it and emits to the other client. When the second client receives the message it sends back an acknowledgement and the server invokes a callback on it. It works when both clients are connected to the same namespace. However the latest callback is not envoked when the clients are connected to different namespaces.
Steps to reproduce:
I have prepared an example consisting of four files: one python script and one template for both situations when the clients are connected to a single namespace and when they are not.
Versions:
Single namespace:
works/main.py
:works/templates/user.html
:If we run this app, then open in a browser http://localhost:5000/user/0 and http://localhost:5000/user/1 and click the button on one of the pages we'll see something like that in the server logs:
Notice the last row. It is created from the
ack_callback
function.Different namespaces Below are slightly modified versions of the files from the
works
directory. The difference is that each user connects to its own namespace and the server emits to one of the namespaces while handling event from the other one. Also it listens to another port.doesnt_work/main.py
:doesnt_work/templates/user.html
:Same again, run this app, then open in a browser http://localhost:5001/user/0 and http://localhost:5001/user/1 and click the button on one of the pages. Then these lines appear in the server logs:
The server states that it has got the acknowledgement from the user 1, however the
ack_callback
function is never called.The expected behaviour:
Both servers envoke the callback.