SockJS python server implementation on top of Tornado framework
Project description
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Description: SockJS-tornado server
=====================
SockJS-tornado is a Python server side counterpart of `SockJS-client browser library <https://github.com/sockjs/sockjs-client>`_
running on top of `Tornado <http://tornadoweb.org>`_ 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 <https://github.com/MrJoes/sockjs-tornado/tree/master/examples>`_ for a complete version).
Subscribe to `SockJS mailing list <https://groups.google.com/forum/#!forum/sockjs>`_ 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 <https://raw.github.com/sockjs/sockjs-node/master/examples/haproxy.cfg>`_.
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)
Changelog
---------
1.0.6
-----
- XSS security fix for the HTMLFILE transport
1.0.2
~~~~~
- Tornado 5.x compatibility fix
1.0.1
~~~~~
- Tornado 4.x compatibility fix
1.0.0
~~~~~
- Major version bump. sockjs-tornado can be considered mature
- Python 3 support
- Tornado 3.0 support on both Python 2 and Python 3
- Bug fixes
0.0.5
~~~~~
- iOS 6 support
- SockJS 0.3.3 client support
- Some headers and request URI path is now passed to on_open handler
- Added binary transport support for raw websocket transport
- Minor multiplex sample fixes
0.0.4
~~~~~
- Added support for older simplejson library versions
- Fixed installation script
0.0.3
~~~~~
- SockJS 0.3 support
- Connection multiplexing sample
- IP validation is now optional
0.0.2
~~~~~
- SockJS 0.2 support and compatibility fixes
0.0.1
~~~~~
Initial release.
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: Implementation :: CPython
Requires: tornado
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Description: SockJS-tornado server
=====================
SockJS-tornado is a Python server side counterpart of `SockJS-client browser library <https://github.com/sockjs/sockjs-client>`_
running on top of `Tornado <http://tornadoweb.org>`_ 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 <https://github.com/MrJoes/sockjs-tornado/tree/master/examples>`_ for a complete version).
Subscribe to `SockJS mailing list <https://groups.google.com/forum/#!forum/sockjs>`_ 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 <https://raw.github.com/sockjs/sockjs-node/master/examples/haproxy.cfg>`_.
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)
Changelog
---------
1.0.6
-----
- XSS security fix for the HTMLFILE transport
1.0.2
~~~~~
- Tornado 5.x compatibility fix
1.0.1
~~~~~
- Tornado 4.x compatibility fix
1.0.0
~~~~~
- Major version bump. sockjs-tornado can be considered mature
- Python 3 support
- Tornado 3.0 support on both Python 2 and Python 3
- Bug fixes
0.0.5
~~~~~
- iOS 6 support
- SockJS 0.3.3 client support
- Some headers and request URI path is now passed to on_open handler
- Added binary transport support for raw websocket transport
- Minor multiplex sample fixes
0.0.4
~~~~~
- Added support for older simplejson library versions
- Fixed installation script
0.0.3
~~~~~
- SockJS 0.3 support
- Connection multiplexing sample
- IP validation is now optional
0.0.2
~~~~~
- SockJS 0.2 support and compatibility fixes
0.0.1
~~~~~
Initial release.
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: Implementation :: CPython
Requires: tornado
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sockjs-tornado-1.0.6.tar.gz
(21.0 kB
view details)
File details
Details for the file sockjs-tornado-1.0.6.tar.gz
.
File metadata
- Download URL: sockjs-tornado-1.0.6.tar.gz
- Upload date:
- Size: 21.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec12b0c37723b0aac56610fb9b6aa68390720d0c9c2a10461df030c3a1d9af95 |
|
MD5 | aeb0592bac81a1ee0e5a5ba45369c707 |
|
BLAKE2b-256 | 8de3dc274dea5feb37af623f18d22a3412466559e52baf6bb559e74883018317 |