You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
vgw80MhB8FnORrEuAAAG: Received packet MESSAGE data 20["sendMessage","1","message from user 0"]
received event "sendMessage" from _k_1C_Va9R5oO6gcAAAH [/]
emitting event "messageFromUser" to room_1 [/]
xcr2FFCJ6gDwlKrxAAAE: Sending packet MESSAGE data 22["messageFromUser","message from user 0"]
vgw80MhB8FnORrEuAAAG: Sending packet MESSAGE data 30["sent to room_1"]
xcr2FFCJ6gDwlKrxAAAE: Received packet MESSAGE data 32["Ack from JS! eventName: messageFromUser, data: \"message from user 0\""]
received ack from YG5EbenDWxb4nZ9WAAAF [/]
[2022-11-20 14:06:28,462] INFO in main: ack!, args=('Ack from JS! eventName: messageFromUser, data: "message from user 0"',), kwargs={}
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.
4QWbYZeo1540Yvk-AAAE: Received packet MESSAGE data 2/namespace_0,0["sendMessage","1","message from user 0"]
received event "sendMessage" from hvr4QyQFdzeFPYXhAAAF [/namespace_0]
emitting event "messageFromUser" to room_1 [/namespace_1]
YmNfuvm_48j3EBGLAAAG: Sending packet MESSAGE data 2/namespace_1,2["messageFromUser","message from user 0"]
4QWbYZeo1540Yvk-AAAE: Sending packet MESSAGE data 3/namespace_0,0["sent to room_1"]
YmNfuvm_48j3EBGLAAAG: Received packet MESSAGE data 3/namespace_1,2["Ack from JS! eventName: messageFromUser, data: \"message from user 0\""]
received ack from qFxd7MstcjebAWuRAAAH [/namespace_1]
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: