Django websocket code is skipped when running server via nginx and asgi

18 views Asked by At

In our code, AsyncJsonWebsocketConsumer.send_json() works fine when we are running the server via Django runserver but gets skipped when it is ran via nginx and asgi.

This is the calling code and it is within an api view:

async_to_sync(channel_layer.group_send)(
'office_id_{}'.format(patient.office.pk),
  {
    'type': 'message_received',
    'patient_id': patient.id,
  }
)

message_received looks like this:

async def message_received(self, event):
    await self.send_json(event)
    

What do we have to do to get this to work under nginx and asgi?

Thanks,

0

There are 0 answers