{"id":1917,"library":"autobahn","title":"Autobahn Python","description":"Autobahn Python is a networking library that provides open-source implementations of the WebSocket Protocol and the Web Application Messaging Protocol (WAMP). It allows developers to create high-performance, asynchronous WebSocket clients and servers, and WAMP clients and application components, running on either Twisted or asyncio event loops. Currently at version 25.12.2, the project maintains an active development pace with frequent nightly and development builds, alongside regular stable releases.","status":"active","version":"25.12.2","language":"python","source_language":"en","source_url":"https://github.com/crossbario/autobahn-python","tags":["websocket","wamp","real-time","networking","asyncio","twisted","rpc","pubsub"],"install":[{"cmd":"pip install autobahn","lang":"bash","label":"Minimal install"},{"cmd":"pip install autobahn[all]","lang":"bash","label":"Full install (includes Twisted, asyncio, encryption, and optional dependencies)"},{"cmd":"pip install autobahn[asyncio,encryption]","lang":"bash","label":"Common asyncio-based install with TLS"},{"cmd":"pip install autobahn[twisted,encryption]","lang":"bash","label":"Common Twisted-based install with TLS"}],"dependencies":[{"reason":"Networking backend for synchronous-like asynchronous programming. Optional, alternatively use asyncio.","package":"Twisted","optional":true},{"reason":"Standard Python asynchronous event loop. Optional, alternatively use Twisted.","package":"asyncio","optional":true},{"reason":"Internal abstraction layer for Twisted and asyncio.","package":"txaio","optional":false},{"reason":"Required for TLS/encryption features (part of 'encryption' extra).","package":"cryptography","optional":true},{"reason":"Required for TLS/encryption features (part of 'encryption' extra).","package":"pyopenssl","optional":true},{"reason":"Required for WAMP-cryptosign authentication (part of 'encryption' extra).","package":"pynacl","optional":true},{"reason":"Required for WAMP-SCRAM authentication (part of 'scram' extra).","package":"argon2-cffi","optional":true}],"imports":[{"symbol":"WebSocketServerProtocol","correct":"from autobahn.asyncio.websocket import WebSocketServerProtocol\n# or: from autobahn.twisted.websocket import WebSocketServerProtocol"},{"symbol":"WebSocketClientProtocol","correct":"from autobahn.asyncio.websocket import WebSocketClientProtocol\n# or: from autobahn.twisted.websocket import WebSocketClientProtocol"},{"symbol":"WebSocketServerFactory","correct":"from autobahn.asyncio.websocket import WebSocketServerFactory\n# or: from autobahn.twisted.websocket import WebSocketServerFactory"},{"symbol":"ApplicationSession","correct":"from autobahn.asyncio.wamp import ApplicationSession\n# or: from autobahn.twisted.wamp import ApplicationSession"},{"note":"Use Component with run() function instead of older ApplicationRunner which lacks features.","wrong":"from autobahn.asyncio.wamp import ApplicationRunner","symbol":"Component","correct":"from autobahn.wamp.component import Component"}],"quickstart":{"code":"import asyncio\nfrom autobahn.asyncio.websocket import WebSocketServerFactory, WebSocketServerProtocol\n\nclass MyServerProtocol(WebSocketServerProtocol):\n    def onConnect(self, request):\n        print(f\"Client connecting: {request.peer}\")\n\n    def onOpen(self):\n        print(\"WebSocket connection open.\")\n\n    def onMessage(self, payload, isBinary):\n        if isBinary:\n            print(f\"Binary message received: {len(payload)} bytes\")\n        else:\n            print(f\"Text message received: {payload.decode('utf8')}\")\n\n        # echo back message verbatim\n        self.sendMessage(payload, isBinary)\n\n    def onClose(self, wasClean, code, reason):\n        print(f\"WebSocket connection closed: {reason} (code={code}, clean={wasClean})\")\n\nasync def main():\n    factory = WebSocketServerFactory(\"ws://127.0.0.1:9000\")\n    factory.protocol = MyServerProtocol\n\n    server = await asyncio.get_event_loop().create_server(factory, '127.0.0.1', 9000)\n    print(\"WebSocket server started on ws://127.0.0.1:9000\")\n\n    try:\n        await server.serve_forever()\n    except KeyboardInterrupt:\n        pass\n    finally:\n        server.close()\n        await server.wait_closed()\n        asyncio.get_event_loop().close()\n\nif __name__ == '__main__':\n    asyncio.run(main())","lang":"python","description":"This quickstart demonstrates a basic WebSocket echo server using the `asyncio` backend. It listens on `ws://127.0.0.1:9000` and echoes back any message it receives. This example can be run directly. For WAMP applications, a separate WAMP Router like Crossbar.io is required."},"warnings":[{"fix":"Ensure your project is running on Python 3.11 or newer.","message":"Autobahn Python has dropped support for older Python versions. As of version 25.12.2, it officially requires Python >=3.11. Older versions supported Python 3.7+ (since v21.2.1) and Python 2 up to v19.11.2.","severity":"breaking","affected_versions":"<25.0.0"},{"fix":"Use `loop = asyncio.new_event_loop(); asyncio.set_event_loop(loop)` at the beginning of the child thread/process execution.","message":"When using asyncio in child threads or subprocesses (e.g., with `multiprocessing`), you must explicitly create and set a new event loop for each new thread/process on Unix-like systems. If you don't, you'll encounter `AssertionError: There is no current event loop in thread '...'`.","severity":"gotcha","affected_versions":"All versions using asyncio in multi-threaded/multi-process contexts"},{"fix":"Run a WAMP router (like Crossbar.io) separately and ensure your WAMP components are configured to connect to it and join the correct realm.","message":"WAMP clients (both Python and JavaScript) require a WAMP router (e.g., Crossbar.io) to mediate communication. Autobahn provides the client/component library, but not the router itself. WAMP servers should also explicitly set the realm they intend to join.","severity":"gotcha","affected_versions":"All WAMP-related versions"},{"fix":"Replace `from autobahn.util import time_ns` with `from txaio import time_ns`.","message":"The `autobahn.util.time_ns` helper was deprecated in favor of `txaio.time_ns` in version 20.1.3.","severity":"deprecated","affected_versions":"<20.1.3"},{"fix":"Remove `accelerate` from your install variants. NVX is often included in platform-specific binary wheels.","message":"The `accelerate` install variant is no longer recommended. Autobahn now includes NVX (Native Vector Extensions) for SIMD-accelerated WebSocket operations (XOR masking and UTF-8 validation), which leverages CFFI for performance.","severity":"deprecated","affected_versions":">=25.11.1"}],"env_vars":null,"search_vec":"'25.12.2':56 'activ':61 'allow':27 'alongsid':70 'applic':22,43 'asynchron':34 'asyncio':50,80 'autobahn':1,3 'build':69 'client':36,41 'compon':44 'creat':30 'current':53 'develop':28,62,68 'either':47 'event':51 'frequent':65 'high':32 'high-perform':31 'implement':14 'librari':8 'loop':52 'maintain':59 'messag':23 'network':7,79 'night':66 'open':12 'open-sourc':11 'pace':63 'perform':33 'project':58 'protocol':18,24 'provid':10 'pubsub':83 'python':2,4 'real':77 'real-tim':76 'regular':71 'releas':73 'rpc':82 'run':45 'server':38 'sourc':13 'stabl':72 'time':78 'twist':48,81 'version':55 'wamp':25,40,75 'web':21 'websocket':17,35,74","created_at":"2026-04-09T18:35:41.511375+00:00","updated_at":"2026-04-15T21:34:12.955742+00:00","problems":[{"fix":"Use 'from autobahn.twisted.websocket import WebSocketClientFactory' instead.","cause":"The import path for 'WebSocketClientFactory' changed in Autobahn version 0.7.0.","error":"ImportError: cannot import name 'WebSocketClientFactory'"},{"fix":"Remove the 'standalone' argument and connect to an external WAMP router like Crossbar.io.","cause":"The 'standalone' argument was removed from 'ApplicationRunner' in Autobahn version 0.7.0.","error":"TypeError: __init__() got an unexpected keyword argument 'standalone'"},{"fix":"Ensure all dependencies are correctly installed and compatible; check the Autobahn TestSuite documentation for proper setup.","cause":"The 'wstest' tool from Autobahn TestSuite encountered an unhandled error, possibly due to misconfiguration or compatibility issues.","error":"Unhandled Error\nTraceback (most recent call last):\n  File \"/usr/local/bin/wstest\", line 9, in <module>\n    load_entry_point('autobahntestsuite==0.5.5', 'console_scripts', 'wstest')()\n..."},{"fix":"Use the class-based 'Component' API to handle events with 'on' decorators.","cause":"The 'on' method is not available in the functional 'Component' API of Autobahn.","error":"AttributeError: 'Component' object has no attribute 'on'"},{"fix":"Verify the server's availability, correct address and port, and ensure no firewalls are blocking the connection. If the server is overloaded, consider optimizing its performance or adjusting the timeout settings on the client if applicable.","cause":"The client attempted to establish a WebSocket connection, but the server did not complete the handshake within the expected time, often due to an overloaded server, incorrect server address/port, or firewall issues.","error":"WebSocket opening handshake timeout (peer did not finish the opening handshake in time)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"26.7.1","cli_name":"","cli_version":null,"type":"library","homepage":"https://autobahn.readthedocs.io/","github":"https://github.com/crossbario/autobahn-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/autobahn/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","web-framework","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}