I have a django application need to be deployed under Apache HTTP Server, also i need push event to client's web browser at real time. I'm rather new to python, could anyone suggest some websocket server could work in Python+Django+Apache?
Django Channels facilitates support of WebSockets in Django in a manner similar to traditional HTTP views. It wraps Django's native asynchronous view support, allowing Django projects to handle not only HTTP, but also protocols that require long-running connections, such as WebSockets, MQTT, chatbots, etc.
With WebSockets (via Django Channels) managing the communication between the client and the server, whenever a user is authenticated, an event will be broadcasted to every other connected user. Each user's screen will change automatically, without them having to reload their browsers.
Fast Reaction TimeWebSockets allow for a higher amount of efficiency compared to REST because they do not require the HTTP request/response overhead for each message sent and received.
Django is a synchronous web server. it means you cannot use websocket directly with it. But you have various option to do websocket in Django.
Use a full python stack to do it: use Tornado and Django. You can follow this post
Use Nodejs + socket.io + message broker : Follow this type of tutorial
You will find more resources to help you doing that with node.js & socket.io than using tornado.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With