Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

websocket server for django application

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?

like image 944
Simon Wang Avatar asked Aug 29 '13 02:08

Simon Wang


People also ask

Does Django support WebSockets?

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.

How does Django WebSockets work?

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.

Is WebSocket Faster Than Rest API?

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.


1 Answers

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.

like image 140
Alex Grs Avatar answered Oct 06 '22 22:10

Alex Grs