Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
786 views
in Technique[技术] by (71.8m points)

websocket - How to build a push system in django?

I need to build a push system in django, basicly its function is to push messages from server to browser.

As nodejs cannot be used, i prefer websocket or orbited, but i've no idea how to implement any of these two in django. pls recommend a method for me, this will help me a lot, thx.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

One option would be to use a WebSocket server running parallel to your Django server which has a REST/Push API, and then do pushes from Django by simply HTTP/POSTing to the WebSocket server, which in turn delivers the messages to all connected WebSocket clients.

That way, you don't need any structural/technical changes to your existing Django app, nevertheless have a scalable, modern WebSocket based push feature.

For a hosted service providing above, I'd have a look at http://pusher.com.

If you prefer running your own, I'd have a look at http://autobahn.ws, which is deployed as a ready-to-run virtual appliance (VMware, VirtualBox, Amazon EC2). You can find working examples of REST/API here https://github.com/tavendo/AutobahnPushPython

Disclaimer: I am author of Autobahn Open-source, and work for Tavendo, which offers Autobahn.ws (the commercial offering based on Autobahn OSS).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...