wiki:Notes/WebSocket

Web Socket

A major technical capability, part of HTML5

http://en.wikipedia.org/wiki/WebSocket

WebSocket is a protocol providing full-duplex communications channels over a single TCP connection. The WebSocket protocol was standardized by the IETF as RFC 6455 in 2011, and the WebSocket API in Web IDL is being standardized by the W3C.

WebSocket is designed to be implemented in web browsers and web servers, but it can be used by any client or server application. The WebSocket Protocol is an independent TCP-based protocol. Its only relationship to HTTP is that its handshake is interpreted by HTTP servers as an Upgrade request.

The WebSocket protocol makes more interaction between a browser and a web site possible, facilitating live content and the creation of real-time games. This is made possible by providing a standardized way for the server to send content to the browser without being solicited by the client, and allowing for messages to be passed back and forth while keeping the connection open.

http://en.wikipedia.org/wiki/Comparison_of_WebSocket_implementations

Protocol

WebSocket Protocol Registries - http://www.iana.org/assignments/websocket/websocket.xml

WebSocket Subprotocol Name Registry

WAMP - http://wamp.ws/spec/

Stomp - http://stomp.github.io/stomp-specification-1.2.html

AMQPWSB10 - http://docs.oasis-open.org/amqp-bindmap/amqp-wsb/v1.0/amqp-wsb-v1.0.html ( AMQP WebSocket Binding )

XMPP RFC7395 - http://www.iana.org/go/rfc7395 ( WebSocket Transport for XMPP ), Couldn't reach ?

Python

https://pypi.python.org/pypi/websockets

Haven't had time to examine and evaluate, but looks promising, most widely used I think. The problem is it needs Python3 , but that may be a fairly minimal limitation as of early 2017.

https://github.com/aaugustin/websockets

https://websockets.readthedocs.io/en/stable/

https://github.com/Lawouach/WebSocket-for-Python

Again, haven't had time to look at, works with Python 2 and 3, operational dependencies include CherryPy ?

https://pypi.python.org/pypi/ws4py

http://mrjoes.github.io/2013/06/21/python-realtime.html - as of early 2013

To sum it up - even though nodejs does its job, I had strong feeling that it is not as mature as Python. And I'd rather use Python for such task in the future, so I can be sure that if something goes wrong, it is happening because I failed and issue can be traced relatively easy.

Performance-wise, with WebSocket transport, CPython is on par with nodejs and PyPy is much faster than both. For long-polling, Tornado on PyPy is approximately 1.5-2 times slower than nodejs when used with proper asynchronous libraries. So, given current WebSocket adoption state, I'd say they're comparable.

Thoughtful, interesting how the author works through myriad combinations of components to achieve a balance between design objectives.

Crossbar.io

Crossbar.io is an open-source WAMP router to build loosely-coupled components talk with each other in real-time.

See: PythonServers/WAMP#Crossbar.io

Full Stack Python

http://www.fullstackpython.com/websockets.html

http://www.fullstackpython.com/

Gevent and SocketIO

https://gevent-socketio.readthedocs.org/en/latest/

Socket.IO is a WebSocket-like abstraction that enables real-time communication between a browser and a server. gevent-socketio is a Python implementation of the protocol.

The reference server implementation of Socket.IO runs on Node.js and was developed by LearnBoost. There are now server implementations in a variety of languages.

One aim of this project is to provide a single gevent-based API that works across the different WSGI-based web frameworks out there (Pyramid, Pylons, Flask, web2py, Django, etc...). Only ~3 lines of code are required to tie-in gevent-socketio in your framework. Note: you need to use the gevent python WSGI server to use gevent-socketio.

https://github.com/abourget/gevent-socketio

https://pypi.python.org/pypi/gevent-socketio

Stuff

http://blog.miguelgrinberg.com/post/easy-websockets-with-flask-and-gevent

http://www.defuze.org/oss/ws4py/docs/

http://www.tornadoweb.org/en/branch2.1/websocket.html

http://tonygaitatzis.tumblr.com/post/61729708977/websocket-server-with-python-tornado

http://bottlepy.org/docs/dev/async.html#finally-websockets

http://nginx.com/blog/realtime-applications-nginx/

Also See

Web Application Messaging Protocol

Search wiki for 'websocket'

Last modified 12 days ago Last modified on 04/17/2017 06:07:31 PM