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
there's an application ("the backend") using python flask socket.io. Multiple browsers ("the frontends") may connect to this application at the same time. One of the use cases requires that the backend sends a message to one of the frontends and to only this one frontend.
To distinguish one frontend from another, we use SocketIO.send() and its concept of "room"s.
The room here is a session id that is generated and sent to the frontend upon user login. The frontend then stores this id in a cookie. It then triggers an event handler which uses the session id (called "room") as argument to join_room():
This way, so I thought, we could specify exactly which frontend to send a message to. But the message gets transferred to all the connected frontends, just like without mentioning the room in SocketIO.send() at all.
Digging into the problem, I found that send() doesn't know a "room" parameter. It uses "to" instead. But after fixing this, none of the connected clients gets the message. Digging deeper, I stumbled over BaseManager.emit() which is called some steps into the stack and checks if (this one is new) namespace exists in its self.rooms list, which is empty.
My question is: What should I do to populate the rooms list?
method. It doesn't get called. Except for seldom occurrences when it does. Not getting called is something I would suppose to have influence on the list of known rooms and therefore on my problem.
What can go wrong (mabe even on the frontend side?) so that an event like the one above doesn't get called? How can we fix this?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi forum,
there's an application ("the backend") using python flask socket.io. Multiple browsers ("the frontends") may connect to this application at the same time. One of the use cases requires that the backend sends a message to one of the frontends and to only this one frontend.
To distinguish one frontend from another, we use SocketIO.send() and its concept of "room"s.
The room here is a session id that is generated and sent to the frontend upon user login. The frontend then stores this id in a cookie. It then triggers an event handler which uses the session id (called "room") as argument to join_room():
The join_room() method doesn't work outside of event handlers.
So we have a session id, have it stored in the backend and get its value as a cookie every time the frontend calls some route
This way, so I thought, we could specify exactly which frontend to send a message to. But the message gets transferred to all the connected frontends, just like without mentioning the room in SocketIO.send() at all.
Digging into the problem, I found that send() doesn't know a "room" parameter. It uses "to" instead. But after fixing this, none of the connected clients gets the message. Digging deeper, I stumbled over BaseManager.emit() which is called some steps into the stack and checks if (this one is new) namespace exists in its self.rooms list, which is empty.
My question is: What should I do to populate the rooms list?
[Update]
There seems to be an issue with the
method. It doesn't get called. Except for seldom occurrences when it does. Not getting called is something I would suppose to have influence on the list of known rooms and therefore on my problem.
What can go wrong (mabe even on the frontend side?) so that an event like the one above doesn't get called? How can we fix this?
Beta Was this translation helpful? Give feedback.
All reactions