Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

SockJS server implementation for aiohttp.

Project description

sockjs is a SockJS integration for aiohttp. SockJS interface is implemented as a aiohttp route. Its possible to create any number of different sockjs routes, ie /sockjs/* or /mycustom-sockjs/*. You can provide different session implementation and management for each sockjs route.

Simple aiohttp web server is required:

use = egg:gunicorn#main
host =
port = 8080
worker = aiohttp.worker.GunicornWebWorker

Example of sockjs route:

def main(global_settings, **settings):
    app = web.Application(loop=loop)
    app.router.add_route('GET', '/', index)
    sockjs.add_endpoint(app, prefix='/sockjs', handler=chatSession)

    handler = app.make_handler()
    srv = loop.run_until_complete(
        loop.create_server(handler, '', 8080))
    print("Server started at")
     except KeyboardInterrupt:

Client side code:

<script src="//"></script>
    var sock = new SockJS('http://localhost:8080/sockjs');

    sock.onopen = function() {

    sock.onmessage = function(obj) {

    sock.onclose = function() {

Supported transports



You can find several examples in the sockjs repository at github.


sockjs is offered under the Apache 2 license.


0.10.0 (2019-10-20)

  • Sync with aiohttp 3.6 (#298)

0.9.1 (2018-12-04)

  • Minor code styling cleanups

0.9.0 (2018-10-11)

  • Support Python 3.7. The minimal available Python version is 3.5.3 (#240)

0.8.0 (2018-06-15)

  • Fix heartbeat (#214)

0.7.1 (2018-03-05)

  • Fix compatibility with aiohttp 3.0+ again.

0.7.0 (2018-02-25)

  • Fixed compatibility with aiohttp 3.0+ (#169)

0.6 (2017-04-13)

  • Fixed support for aiohttp 2.0+.

0.5 (2016-09-26)

  • Mark SockJSRoute.handler and SockJSRoute.websocket as coroutines. #25
  • Remove a check for “ORIGIN” header #12
  • Process FRAME_MESSAGE_BLOB message type #12

0.4 (2016-02-04)

  • Fixed lost event-loop argument in sockjs.transports.websocket.WebSocketTransport
  • Fixed lost event-loop argument in sockjs.transports.rawwebsocket.RawWebSocketTransport
  • Fixed RawRequestMessage. Add raw_header argument (aiohttp 0.21+)
  • Fixed many warnings
  • Fixed sockjs.route add_endpoint without name bug

0.3 (2015-08-07)

  • Fixed calls of SessionManager.aquire() - was removed the unnecessary second argument.
  • Fixed the incorrect argument in one call of cors_headers().
  • Fixed many errors. The code is not perfect, but at least it was working as it should.

0.2 (2015-07-07)

  • Fixed packaging

0.1.0 (2015-06-21)

  • Initial release

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sockjs, version 0.10.0
Filename, size File type Python version Upload date Hashes
Filename, size sockjs-0.10.0-py3-none-any.whl (23.2 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size sockjs-0.10.0.tar.gz (31.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page