sockjs-tornado

Software Screenshot:
sockjs-tornado
Software Details:
Version: 0.0.4
Upload Date: 14 Apr 15
Developer: Serge S. Koval
Distribution Type: Freeware
Downloads: 6

Rating: nan/5 (Total Votes: 0)

sockjs-tornado is a Python server side counterpart of SockJS-client browser library running on top of Tornado framework.

Simplified echo SockJS server could look more or less like:

from tornado import web, ioloop
from sockjs.tornado import SockJSRouter, SockJSConnection

class EchoConnection(SockJSConnection):
 def on_message(self, msg):
 self.send(msg)

if __name__ == '__main__':
 EchoRouter = SockJSRouter(EchoConnection, '/echo')

 app = web.Application(EchoRouter.urls)
 app.listen(9999)
 ioloop.IOLoop.instance().start()


(Take look at examples for a complete version).

Subscribe to SockJS mailing list for discussions and support.

SockJS-tornado API

SockJS provides slightly different API than _tornado.websocket_. Main differences are:

- Depending on transport, actual client connection might or might not be there. So, there is no _self.request_ and other _tornado.web.RequestHandler_ properties.
- Changed _open_ callback name to _on_open_ to be more consistent with other callbacks.
- Instead of _write_message_, all messages are sent using _send_ method. Just in case, _send_ in _tornado.web.RequestHandler_ sends raw data over the connection, without encoding it.
- There is handy _broadcast_ function, which accepts list (or iterator) of clients and message to send.

Settings

You can pass various settings to the _SockJSRouter_, in a dictionary:

MyRouter = SockJSRouter(MyConnection, '/my', dict(disabled_transports=['websocket']))

Deployment

sockjs-tornado properly works behind haproxy and it is recommended deployment approach.

Sample configuration file can be found here.

If your log is full of "WARNING: Connection closed by the client", pass _no_keep_alive_ as _True_ to _HTTPServer_ constructor:

HTTPServer(app, no_keep_alive=True).listen(port)

or:

app.listen(port, no_keep_alive=True)

What is new in this release:

  • Added support for older simplejson library versions
  • Fixed installation script

Requirements:

  • Python

Other Software of Developer Serge S. Koval

TornadIO
TornadIO

11 May 15

Flask-Admin
Flask-Admin

10 Dec 15

TornadIO2
TornadIO2

14 Apr 15

Comments to sockjs-tornado

Comments not found
Add Comment
Turn on images!