Skip to main content

asyncio-friendly Python wrapper for libdatachannel (WebRTC Data Channels)

Project description

aiolibdatachannel

An asyncio-friendly Python wrapper around libdatachannel — a lightweight C/C++ WebRTC stack. aiolibdatachannel exposes WebRTC Peer Connections and Data Channels through idiomatic async/await Python.

Scope: PeerConnection + DataChannel only. WebSocket and Media/RTP transport are deliberately disabled in this build to keep the wheel small and the API focused.

Install

pip install aiolibdatachannel

Wheels are published for Linux (manylinux_2_34 x86_64 / aarch64) and macOS (arm64, 14.0+) per CPython version (cp312 / cp313 / cp314). Intel Macs and Windows aren't currently covered — Intel Mac because Apple Silicon is the modern target, Windows because libdatachannel dynamically links OpenSSL and the wheel packaging for that on Windows is still open.

ℹ️ Earlier releases shipped a single cp312-abi3 wheel covering all CPython 3.12+. The bundled OpenSSL inside that wheel collided with the OpenSSL CPython itself loads via _ssl / hashlib (process- global PRNG / FIPS state), which segfaulted on first PeerConnection use under CPython 3.14. We now publish per-version wheels so each binary lines up with the matching interpreter ABI.

The Python↔C boundary uses nanobind: libdatachannel and its static dependencies (usrsctp, libjuice, OpenSSL) link directly into the extension. The binding layer itself is deliberately thin: native trampolines route every libdatachannel callback through a single Python dispatcher, and the asyncio semantics live in the pure-Python wrapper on top, not in C++.

Quickstart

import asyncio
from aiolibdatachannel import PeerConnection, RTCConfiguration

async def main() -> None:
    config = RTCConfiguration(ice_servers=["stun:stun.l.google.com:19302"])

    async with PeerConnection(config) as pc:
        dc = await pc.create_data_channel("chat")

        offer = await pc.create_offer()
        # ... ship `offer` to the peer via your signalling channel ...
        answer_sdp = await receive_answer_from_peer()
        await pc.set_remote_description(answer_sdp, "answer")

        await dc.wait_open()
        await dc.send(b"hello")

        async for message in dc:
            print("got", message)

asyncio.run(main())

See examples/offerer.py and examples/answerer.py for a runnable pair of scripts that negotiate over stdin/stdout.

Logging

Route libdatachannel's internal logs through Python's standard logging module:

import logging
from aiolibdatachannel import install_python_logger

logging.basicConfig(level=logging.INFO)
install_python_logger()  # logger name defaults to "aiolibdatachannel"

Severities are translated (FATAL→CRITICAL, ERROR→ERROR, WARNING→WARNING, INFO→INFO, DEBUG/VERBOSE→DEBUG) and the filter threshold on the native side is derived from the Python logger's effective level, so you don't pay to format lines that would be filtered out anyway. Pass install_python_logger(my_logger) or install_python_logger(level=LogLevel.DEBUG) to customise.

Development

Full native build (requires a C++17 toolchain, CMake ≥ 3.24, ninja, and OpenSSL headers):

git clone --recursive https://github.com/social-home-io/aiolibdatachannel.git
cd aiolibdatachannel
pip install -e .[dev]
pytest

If you only need to touch the Python wrapper (async semantics, async iterators, event plumbing), skip the C++ build and run against the pure-Python stand-in from tests/_fake_native.py:

pip install pytest pytest-asyncio
PYTHONPATH=. pytest -m "not native"

tests/conftest.py injects the fake into sys.modules whenever AIOLIB_REQUIRE_NATIVE is unset. Tests marked @pytest.mark.native (loopback, cancellation, logging, errors, stress) are auto-skipped in that mode.

Long-running soak tests (10 000-message loopback, 100 PC lifecycles, shutdown-leak subprocess checks) live behind a stress marker and are off by default — enable with pytest -m stress or AIOLIB_STRESS=1 pytest. They also run nightly in CI.

See docs/BUILDING.md for detailed build instructions, including how to switch TLS backends and how to bump the bundled libdatachannel version.

License

This project is licensed under the Mozilla Public License 2.0, matching the license of libdatachannel which it bundles and statically links. See LICENSE and vendor/libdatachannel/LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiolibdatachannel-2026.5.22.tar.gz (11.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

aiolibdatachannel-2026.5.22-cp314-cp314-manylinux_2_34_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

aiolibdatachannel-2026.5.22-cp314-cp314-manylinux_2_34_aarch64.whl (4.9 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ ARM64

aiolibdatachannel-2026.5.22-cp314-cp314-macosx_14_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

aiolibdatachannel-2026.5.22-cp313-cp313-manylinux_2_34_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

aiolibdatachannel-2026.5.22-cp313-cp313-manylinux_2_34_aarch64.whl (4.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

aiolibdatachannel-2026.5.22-cp313-cp313-macosx_14_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

aiolibdatachannel-2026.5.22-cp312-cp312-manylinux_2_34_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

aiolibdatachannel-2026.5.22-cp312-cp312-manylinux_2_34_aarch64.whl (4.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

aiolibdatachannel-2026.5.22-cp312-cp312-macosx_14_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

File details

Details for the file aiolibdatachannel-2026.5.22.tar.gz.

File metadata

  • Download URL: aiolibdatachannel-2026.5.22.tar.gz
  • Upload date:
  • Size: 11.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aiolibdatachannel-2026.5.22.tar.gz
Algorithm Hash digest
SHA256 a21f142687dd516cc52fc5c22711e1e9319aee25c6c91c6e4c7fa807c83c2c04
MD5 a272358b3dd4eafa2356fce95ab609b5
BLAKE2b-256 7bd97a4e44714e693c6b84e20312d5a4471f81404dd63600540c64aa08ec29d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.22.tar.gz:

Publisher: release.yml on social-home-io/aiolibdatachannel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiolibdatachannel-2026.5.22-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.22-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 87c837181297923d736d60005e01d787c05566ab475be8a408d7fbb9301aeb49
MD5 8d21a1cb73b82858302209ddf484af79
BLAKE2b-256 e8779675339dab690280c5ecb127b13ba29d5cd2f8858ee312dfb213d21e2051

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.22-cp314-cp314-manylinux_2_34_x86_64.whl:

Publisher: release.yml on social-home-io/aiolibdatachannel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiolibdatachannel-2026.5.22-cp314-cp314-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.22-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 4f04e201f12aab75fddc551a1d2ad8ca2dd5721a41c735f9e368de5e13c3b7b4
MD5 948a22aba451724d6eff268b3e902530
BLAKE2b-256 73718f5ac82bf951c875ea8d4cd454343237baee72e5ce0e701044b68688915b

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.22-cp314-cp314-manylinux_2_34_aarch64.whl:

Publisher: release.yml on social-home-io/aiolibdatachannel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiolibdatachannel-2026.5.22-cp314-cp314-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.22-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 d1ce4f2d359ad82979c95455fdfe43f905390e27a7f864d4026eeb3b4f05c9c9
MD5 bb3bb1e1715f95fd75f024aef6c8ac3f
BLAKE2b-256 dbb0a91677b8409a32edadff498f877a884489593c5aebe8a0b0557bc463b5b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.22-cp314-cp314-macosx_14_0_arm64.whl:

Publisher: release.yml on social-home-io/aiolibdatachannel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiolibdatachannel-2026.5.22-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.22-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 145c7d0b438fc434e88608251cd81cccd40985a81b63bf098ec16596efed6a94
MD5 37338c476c65c127b5224c6b83d4125d
BLAKE2b-256 b1816a8dd89623ebfafa75ccdd2a7f11e94fce4b6d3fc250d6343289061016f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.22-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: release.yml on social-home-io/aiolibdatachannel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiolibdatachannel-2026.5.22-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.22-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 3e4192ce19dfdd2e8678c11e6d42a72315b8800a7fe037356c01d38e4e9d0587
MD5 2413d7cc081044b824e70100929d8ef6
BLAKE2b-256 d472513eed3894f0d40416cbeb115af81ae89567643cf57d9160bc5845ae25ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.22-cp313-cp313-manylinux_2_34_aarch64.whl:

Publisher: release.yml on social-home-io/aiolibdatachannel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiolibdatachannel-2026.5.22-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.22-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 37397e4bb0e6b1bbe13dbca3feb904af6f34ee9ff131c46de56106db2885f792
MD5 8abd0c76bcbe9d38d48d92a56ed1d393
BLAKE2b-256 4d70d1248d97d4b2b27ce6c5c0b7b8d657eacbdb1940bea36171e95f4466be1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.22-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: release.yml on social-home-io/aiolibdatachannel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiolibdatachannel-2026.5.22-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.22-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 684ff2589c69ce89aca79b6931e184f403964b18520598abeba3518e8b7fa7a0
MD5 9d3fc76a6b5efae39268da6db3b3d1b8
BLAKE2b-256 6387c0db63d6a44cb16233bc139c7b3d72f0d7bca8edde56d7bf40b7a4912331

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.22-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: release.yml on social-home-io/aiolibdatachannel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiolibdatachannel-2026.5.22-cp312-cp312-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.22-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 542c49209bb07c000b7f5e0521ede4e5b1a78a34afb2ac7a4b9e229443760a13
MD5 afa49607e1c1e98d3b10761deec9fca6
BLAKE2b-256 970d463c625ba83bcba8815e734024f9147ec211ab61f0078f44ab543e2cb099

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.22-cp312-cp312-manylinux_2_34_aarch64.whl:

Publisher: release.yml on social-home-io/aiolibdatachannel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiolibdatachannel-2026.5.22-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.22-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 52ec703c4bea06ac1a432d8070fd1e1cba9eb6698b4cc50ea86ddd553175e3da
MD5 33e7471ae38826a1d4b854a71d8a8072
BLAKE2b-256 c2c6bef9940bfdf3c656b50ec233163b66ffdd92dedefea8c62e4a0ad117e4b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.22-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: release.yml on social-home-io/aiolibdatachannel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page