Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
WebSocket library for Python (ws4py). Last version 0.2.0.
Python Shell JavaScript
branch: master

This branch is 316 commits behind Lawouach:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

WebSocket for Python (ws4py)

Python library providing support for the WebSocket protocol defined in RFC 6455 (

Getting Started


As a standalone client, ws4py only requires Python 2.6.6 or above though it hasn't been ported to Python 3.x yet.


In order to install ws4py you can either grab the source code and run:

 $ python install

Or use a package manager like pip and run:

 $ pip install git+git://


Online documentation can be found at:


ws4py tries hard to be as conformant as it can to the specification. In order to validate this conformance, each release is run against the Autobahn testsuite ( which provides an extensive converage of various aspects of the protocol.

You may try to run it against the CherryPy server as follow:

 $ python test/

Then from a different terminal:

 $ cd Autobahn/testsuite/websockets
 $ python

This will run the complete suite.

Test reports can be found at:


ws4py comes with a few examples:

  • The echo_cherrypy_server provides a simple Echo server. It requires CherryPy 3.2.2. Once started, you can point your browser (it has been tested with Chrome 15.0.854.0). Open a couple of tabs pointing at http://localhost:9000 and chat accross those tables.
  • The droid_sensor_cherrypy_server broadcasts sensor metrics to clients. Point your browser to http://localhost:9000 Then run the droid_sensor module from your Android device using SL4A. A screenshot of what this renders to:


Many thanks to the pywebsocket and Tornado projects which have provided a good base to write ws4py. Thanks also to Jeff Lindsay (progrium) for the gevent server support. A well deserved thank you to Tobias Oberstein for his websocket test suite:

The background in the droid example is courtesy of

Something went wrong with that request. Please try again.