Please suggest to me a workaround on how to send message to groups on
AsyncJsonWebsocketConsumer.disconnect()?
class UserConsumer(AsyncJsonWebsocketConsumer):
... // some code
async def disconnect(self, close_code: str) -> None:
channel_layer = get_channel_layer()
await channel_layer.group_send(
"some_group", {"type": "send_message", "message": "some test
message"},
)
This is a simple example of my code. When I do this, I've got error:
File
"/home/user/.pyenv/versions/3.8.6/envs/venv38/lib/python3.8/site-packages/channels_redis/core.py",
line 666, in group_send await connection.zremrangebyscore(
aioredis.errors.ConnectionForcedCloseError
I think, disconnect() method is not the best place to send messages. If
yes, what is a good place for this?
Some useful links:
-
https://channels.readthedocs.io/en/latest/topics/consumers.html?#asyncwebsocketconsumer
-
https://aioredis.readthedocs.io/en/v1.3.0/api_reference.html#aioredis.ConnectionForcedCloseError
-
my error that raised by aioredis
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/437e3bd7-fe0d-4ce9-b26b-37c21a2403a8n%40googlegroups.com.