Files explanation in repo:
app.py : contains http and websocket endpoints
room_manager.py : has Room and RoomManager classes.
connection_manger.py: default connection manager provided by fastapi docs. Used to store temporary connections before user is part of any room.
This is the link to the cmd log.
The error "RuntimeError: Unexpected ASGI message 'websocket.send', after sending 'websocket.close'" literally means that you are trying to send a message on a connection that was closed. From what I understand from your question you are keeping a list of users that are part of a room when a user enters the room and you are broadcasting this welcome message to all the other users of the room. But what if a user has disconnected or the underlying connection of a particular user s closed? In this case you'll get the above mentioned error.
What can solve this problem is you should always check for connection closed exception while reading/ writing messages on a connection and should mark the user disconnected if such exception occurs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With