get_channel_layer().group_send does not work inside a celery task
juliGer opened this issue · comments
Hi, I wanted to ask if this was possible to do with channels and celery, I'm trying to send a message through the group_send from a celery task but it doesn't work.
The function is executed but the message is never sent to the channel, does anyone have any idea if this is possible to do ?
Below I leave the code of the celery task
@shared_task(ignore_result=True)
def arrival_message(chat_message):
room_group_name = 'chat_%s' % str(chat_message.chat_session.code)
async_to_sync(get_channel_layer().group_send)(room_group_name, {
'type': 'arrival_message',
'action': 'arrival_message',
'message': model_to_dict(chat_message)})
And I call it as follows arrival_message.delay(chat_message)
Thanks, greetings