Files
deb-python-autobahn/examples/twisted/websocket/echo_compressed
Tobias Oberstein 5da80641ac fixes for Python 3
2013-12-29 22:25:22 +01:00
..
2013-12-29 22:25:22 +01:00
2013-12-29 22:25:22 +01:00
2013-12-23 00:13:34 +01:00
2013-12-23 00:13:34 +01:00
2013-12-29 22:25:22 +01:00
2013-12-29 22:25:22 +01:00

WebSocket Echo Server and Client

This example demonstrates how to activate and use the WebSocket compression extension (permessage-deflate).

Running

Run the server by doing

python server.py

and open

http://localhost:8080/

in your browser.

Note: Currently (06/04/2013), the only browsers implementing WebSocket permessage-deflate are Chrome Canary and Chromium (Dev Channel). To enable, go to chrome://flags/ and enable the "experimental WebSocket implementation".

To activate debug output on the server, start it

python server.py debug

To run the Python client, do

python client.py ws://127.0.0.1:9000

To activate debug output on the client, start it

python client.py ws://127.0.0.1:9000 debug

Advanced Usage

AutobahnPython supports fine-grained control over which compression offers a client makes and exactly which offers a server accepts with which settings.

See server_advanced.py and client_advanced.py.

Besides permessage-deflate, AutobahnPython also supports

  • permessage-bzip2
  • permessage-snappy

Note: Those compression extensions are currently entirely non-standard, there isn't even a RFC draft for those.

For permessage-snappy, you will need the Snappy compression library and Python wrapper installed.

On Windows, you can get a prebuilt binary from here.

On Linux/Debian, you can install it by doing:

sudo apt-get install libsnappy-dev
easy_install -U python-snappy