Home > Software design >  Django Channels with Angular 14 Frontend
Django Channels with Angular 14 Frontend

Time:12-13

is there a way to create a socket with django and a angular 14 frontend? I've tried that with ngx-socket-io, but its not working so far.

Any ideas how to solve this issue? I need to "poll" status from multiple celery tasks, so it's not effective to call the backend n (n=quantity of tasks) every x seconds to get the latest status.

CodePudding user response:

If you're set to use Django & Django-Channels for your backend, then you can't use ngx-socket-io because channels does not support Socket IO. What you can do is use WebSockets in your frontend which is what channels was made for:

Channels is a project that takes Django and extends its abilities beyond HTTP - to handle WebSockets, chat protocols, IoT protocols, and more

I suggest reading this guide to help you create an abstraction layer for the WebSocket: How to implement WebSockets in Angular Project.

You might also want to consider migrating to Flask as it has a package that supports Socket-IO.

  • Related