[Django]-Django Channels Error: you cannot use AsyncToSync in the same thread as an async event loop

3👍

I think you need to replace this calls:

 await async_to_sync(self.channel_layer.group_add)(
        self.room_group_name,
        self.channel_name
    )

await async_to_sync(self.channel_layer.group_discard)(
        self.room_group_name,
        self.channel_name
    )

with this just await:

await self.channel_layer.group_add(
        self.room_group_name,
        self.channel_name
    )

await self.channel_layer.group_discard(
        self.room_group_name,
        self.channel_name
    )

Leave a comment