Skip to main content

SockJS-tornado server

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:

  1. Depending on transport, actual client connection might or might not be there. So, there is no _self.request_ and

    other tornado.web.RequestHandler properties.

  2. Changed open callback name to on_open to be more consistent with other callbacks.

  3. 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.

  4. 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)

Metadata

Release files for saet-sockjs-tornado 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for saet-sockjs-tornado 2.0.1
File Size Uploaded Provenance
saet_sockjs_tornado-2.0.1.tar.gz 21.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for saet-sockjs-tornado 2.0.1
File Interpreter ABI Platform
saet_sockjs_tornado-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 52.8 kB

Release files / saet_sockjs_tornado-2.0.1.tar.gz

Download URL saet_sockjs_tornado-2.0.1.tar.gz
Size 21.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e8b9a47adf71671346fd6f7891aeeae361b9ed5c5dab399f0044e4118ec44888
BLAKE2b-256 checksum
How to use checksums
52b86ea0edc9976f930a105673d2a85dd1d5502085feb2126253d5c0491b4c67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.2

Release files / saet_sockjs_tornado-2.0.1-py3-none-any.whl

Download URL saet_sockjs_tornado-2.0.1-py3-none-any.whl
Size 31.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ac2504969c108ab1f254914f69c52d730e36f89b875d9a7521c9ce05cf5dc39
BLAKE2b-256 checksum
How to use checksums
2757c99301c259d2cc818010afaf34e8c29b8b582a76372d7883fbfdcbb0cdcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.2

Security for saet-sockjs-tornado 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page