MCPcopy Index your code
hub / github.com/crossbario/autobahn-python

github.com/crossbario/autobahn-python @v26.6.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v26.6.2 ↗ · + Follow
5,653 symbols 18,283 edges 473 files 1,669 documented · 30%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Autobahn|Python

WebSocket & WAMP for Python on Twisted and asyncio.

PyPI Python CI CI (wstest) CD (wheels) CD (wheels-arm64) CD (wheels-docker) Docs License Downloads


Quick Links: Source Code - Documentation - WebSocket Examples - WAMP Examples Community: Forum - StackOverflow - Twitter - IRC #autobahn/chat.freenode.net Companion Projects: Autobahn|JS - Autobahn|Cpp - Autobahn|Testsuite - Crossbar.io - WAMP

Introduction

Autobahn|Python is a subproject of Autobahn and provides open-source implementations of

for Python 3.11+ and running on Twisted and asyncio.

You can use Autobahn|Python to create clients and servers in Python speaking just plain WebSocket or WAMP.

WebSocket allows bidirectional real-time messaging on the Web and beyond, while WAMP adds real-time application communication on top of WebSocket.

WAMP provides asynchronous Remote Procedure Calls and Publish & Subscribe for applications in one protocol running over WebSocket. WAMP is a routed protocol, so you need a WAMP Router to connect your Autobahn|Python based clients. We provide Crossbar.io, but there are other options as well.

Note

Autobahn|Python currently requires Python 3.11 or later. Earlier release lines supported older Python versions: up to version v19.11.2 supported Python 2 and 3.4+, up to version v20.7.1 supported Python 3.5+, and up to version v21.2.1 supported Python 3.6+.

Features

  • framework for WebSocket and WAMP clients and servers
  • runs on CPython and PyPy <https://pypy.org/>
  • runs under Twisted and asyncio - implements WebSocket RFC6455 and Draft Hybi-10+
  • implements WebSocket compression
  • implements WAMP, the Web Application Messaging Protocol
  • high-performance, fully asynchronous implementation
  • best-in-class standards conformance (100% strict passes with Autobahn Testsuite: Client Server)
  • message-, frame- and streaming-APIs for WebSocket
  • supports TLS (secure WebSocket) and proxies
  • Open-source (MIT license)

AI Policy

IMPORTANT: A Note on Upcoming Policy Changes Regarding AI-Assisted Content

Up to and including release v25.6.1, this project contains no code or documentation generated with the assistance of AI tools. This version represents the final release under our historical contribution policy. Starting with future versions (after release v25.6.1), our contribution policy will change. Subsequent releases MAY contain code or documentation created with AI assistance.

We urge all users and contributors to review our AI Policy. This document details:

  • The rules and warranties required for all future contributions.
  • The potential intellectual property implications for the project and its users.

This policy was established following an open community discussion, which you can review on GitHub issue #1663.

We are providing this transparent notice to enable you to make an informed decision. If our new AI policy is incompatible with your own (or your organization's) development practices or risk tolerance, please take this into consideration when deciding whether to upgrade beyond version v25.6.1.

Show me some code

To give you a first impression, here are two examples. We have lot more in the repo.

WebSocket Echo Server

Here is a simple WebSocket Echo Server that will echo back any WebSocket message received:

from autobahn.twisted.websocket import WebSocketServerProtocol
# or: from autobahn.asyncio.websocket import WebSocketServerProtocol

class MyServerProtocol(WebSocketServerProtocol):

    def onConnect(self, request):
        print("Client connecting: {}".format(request.peer))

    def onOpen(self):
        print("WebSocket connection open.")

    def onMessage(self, payload, isBinary):
        if isBinary:
            print("Binary message received: {} bytes".format(len(payload)))
        else:
            print("Text message received: {}".format(payload.decode('utf8')))

        # echo back message verbatim
        self.sendMessage(payload, isBinary)

    def onClose(self, wasClean, code, reason):
        print("WebSocket connection closed: {}".format(reason))

To actually run above server protocol, you need some lines of boilerplate.

WAMP Application Component

Here is a WAMP Application Component that performs all four types of actions that WAMP provides:

  1. subscribe to a topic
  2. publish an event
  3. register a procedure
  4. call a procedure

    from autobahn.twisted.wamp import ApplicationSession

    or: from autobahn.asyncio.wamp import ApplicationSession

    class MyComponent(ApplicationSession):

    @inlineCallbacks
    def onJoin(self, details):
    
        # 1. subscribe to a topic so we receive events
        def onevent(msg):
            print("Got event: {}".format(msg))
    
        yield self.subscribe(onevent, 'com.myapp.hello')
    
        # 2. publish an event to a topic
        self.publish('com.myapp.hello', 'Hello, world!')
    
        # 3. register a procedure for remote calling
        def add2(x, y):
            return x + y
    
        self.register(add2, 'com.myapp.add2')
    
        # 4. call a remote procedure
        res = yield self.call('com.myapp.add2', 2, 3)
        print("Got result: {}".format(res))
    

Above code will work on Twisted and asyncio by changing a single line (the base class of MyComponent). To actually run above application component, you need some lines of boilerplate and a WAMP Router.

Packaging

The Autobahn|Python OSS project:

  • build & publish binary wheels on GitHub Releases and PyPI
  • plans to publish on pyx once that launches
  • plans to support WheelNext once that launches (see also: https://lwn.net/Articles/1028299/, https://labs.quansight.org/blog/python-wheels-from-tags-to-variants)
  • no longer bakes & publishes Docker images *
  • no longer explicitly supports PyInstaller packaging

: for commercial users, typedef int GmbH (Germany)*, original creator and active maintainer of Autobahn, Crossbar.io and WAMP provides production grade, optimized and supported Docker images based on RHEL 9 and Debian 12, including complete SBOM for both the base system and full Python application run-time environment based on CycloneDX v1.6 in JSON format and as a audit-level PDF/A document fulfilling strict cybersecurity requirements addressing e.g. EU CRA and BSI TR-03183.

Package Releases

Autobahn|Python publishes source distributions and pre-built wheels on PyPI and GitHub Releases. The current release line requires Python 3.11 or later and publishes wheels for CPython 3.11 through 3.14 and PyPy 3.11 across supported Linux, macOS, and Windows targets.

The recommended installation method is:

python -m pip install autobahn

Pip will choose the best matching wheel for your Python implementation, operating system, and CPU architecture. See the wheels inventory for the supported wheel matrix and NVX acceleration notes.

Extensions

Networking framework

Autobahn runs on both Twisted and asyncio. To select the respective netoworking framework, install flavor:

  • asyncio: Backwards-compatible no-op. Asyncio is included in the Python standard library for all supported Python versions.
  • twisted: Install Twisted and Twisted support in Autobahn

WebSocket Acceleration and Compression

Acceleration (Deprecated)

The accelerate optional dependency is no longer recommended. Autobahn now includes NVX (Native Vector Extensions), which provides SIMD-accelerated native code for WebSocket operations (XOR masking and UTF-8 validation) using CFFI. See the NVX section below for details.

  • ~~accelerate~~: Deprecated - Use NVX instead

Compression

Autobahn supports multiple WebSocket per-message compression algorithms via the compress optional dependency:

pip install autobahn[compress]

Compression Methods Available:

Method Availability Standard Implementation Notes
permessage-deflate Always RFC 7692 Python stdlib (zlib) Standard WebSocket compression
permessage-brotli [compress] RFC 7932 brotli / brotlicffi Recommended - Best compression ratio
permessage-bzip2 Optional Non-standard Python stdlib (bz2) Requires Python built with libbz2
permessage-snappy Manual install Non-standard python-snappy Requires separate installation

Platform-Optimized Brotli Support:

Autobahn includes Brotli compression with full binary wheel coverage optimized for both CPython and PyPy:

  • CPython: Uses brotli (Google's official package, CPyExt)
  • PyPy: Uses brotlicffi (CFFI-based, optimized for PyPy)

Advantages of Brotli: - Superior compression ratio compared to deflate or snappy - Binary wheels for all major platforms (Linux x86_64/ARM64, macOS x86_64/ARM64, Windows x86_64) - IETF standard (RFC 7932) for HTTP compression - Fast decompression suitable for real-time applications - Widely adopted by browsers and CDNs

Resources: - RFC 7932 - Brotli Compressed Data Format - Google Brotli - Official implementation - brotlicffi - CFFI bindings for PyPy - PyPI: brotlicffi - WAMP Brotli Extension Discussion

Note on Snappy:

Snappy compression is available but requ

Core symbols most depended-on inside this repo

get
called by 426
examples/twisted/wamp/app/keyvalue/store.py
Offset
called by 425
src/autobahn/flatbuffers/table.py
Get
called by 305
src/autobahn/flatbuffers/table.py
decode
called by 159
src/autobahn/wamp/cryptobox.py
PrependUOffsetTRelativeSlot
called by 155
src/autobahn/flatbuffers/builder.py
encode
called by 142
src/autobahn/wamp/cryptobox.py
run
called by 140
examples/asyncio/wamp/rawsocket/runner.py
call
called by 139
src/autobahn/wamp/interfaces.py

Shape

Method 3,168
Function 1,756
Class 694
Route 35

Languages

Python98%
TypeScript1%
C1%

Modules by API surface

src/autobahn/wamp/message.py344 symbols
src/autobahn/flatbuffers/flexbuffers.py180 symbols
src/autobahn/websocket/protocol.py121 symbols
src/autobahn/wamp/gen/wamp/proto/Publish.py116 symbols
src/autobahn/wamp/types.py107 symbols
src/autobahn/wamp/interfaces.py91 symbols
src/autobahn/wamp/test/test_wamp_message.py86 symbols
src/autobahn/wamp/gen/wamp/proto/Invocation.py81 symbols
src/autobahn/wamp/gen/wamp/proto/Event.py81 symbols
src/autobahn/wamp/gen/wamp/proto/Call.py78 symbols
src/autobahn/wamp/test/test_wamp_protocol.py74 symbols
src/autobahn/wamp/protocol.py73 symbols

For agents

$ claude mcp add autobahn-python \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact