Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sockjs - Send message to sockjs-tornado in Python code

I use https://github.com/mrjoes/sockjs-tornado for a Django app. I can send messages from javascript console very easy. But I want to create a signal in Django and send json string once the signal is active.

Could anyone give me a way to send a certain message in Python to sockjs-tornado socket server?

like image 582
anhtran Avatar asked Sep 12 '12 07:09

anhtran


1 Answers

There are few options how to handle it:

  1. Create simple REST API in your Tornado server and post your updates from Django using this API;
  2. Use Redis. Tornado can subscribe to the update key and Django can publish updates to this key when something happens;
  3. Use ZeroMQ (AMQP, etc) to send updates from the Django to the Tornado backend (variation of the 1 and 2).

In most of the cases, it is either first or second option. Some people prefer using 3rd option though.

like image 63
Joes Avatar answered Nov 04 '22 00:11

Joes