Cleaning up Room On Disconnect #2074
-
Hello! I have a question related to rooms when running with an external message queue (I.E. Redis) (and apologies if this question is better suited for the When a client disconnects, are they automatically removed from the room? I couldn't find this happening from a quick scan of the code, and now I'm wondering if my Redis storage consumption will continually grow if I don't manually call |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Rooms are automatically garbage collected when they become empty. When a user disconnects they are removed from all the rooms they're in. Also nothing is stored on Redis, all storage is Python process memory. Redis is only used for sending notifications between processes. The logic that removes a user from all the rooms is here if you want to review it. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the quick reply and the link to the code! This mostly clarifies things. So just to confirm, if clients "A" and "B" are connected to process "Foo", and clients "C" and "D" are connected to process "Bar", and all clients are joined to room "Room", then a notification to room "Room" from process "Foo" will propagate to clients "C" and "D" by way of a message sent over the Redis pubsub channel? Since otherwise the process "Bar" would have no way of knowing about the notification. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for your help (and for getting back so quickly). |
Beta Was this translation helpful? Give feedback.
Rooms are automatically garbage collected when they become empty. When a user disconnects they are removed from all the rooms they're in. Also nothing is stored on Redis, all storage is Python process memory. Redis is only used for sending notifications between processes.
The logic that removes a user from all the rooms is here if you want to review it.