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.10.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.10-cp314-cp314-manylinux_2_34_x86_64.whl (5.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

aiolibdatachannel-2026.5.10-cp314-cp314-manylinux_2_34_aarch64.whl (4.8 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.14macOS 14.0+ ARM64

aiolibdatachannel-2026.5.10-cp313-cp313-manylinux_2_34_x86_64.whl (5.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

aiolibdatachannel-2026.5.10-cp313-cp313-manylinux_2_34_aarch64.whl (4.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.13macOS 14.0+ ARM64

aiolibdatachannel-2026.5.10-cp312-cp312-manylinux_2_34_x86_64.whl (5.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

aiolibdatachannel-2026.5.10-cp312-cp312-manylinux_2_34_aarch64.whl (4.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

aiolibdatachannel-2026.5.10-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.10.tar.gz.

File metadata

  • Download URL: aiolibdatachannel-2026.5.10.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.10.tar.gz
Algorithm Hash digest
SHA256 73d3a43c913a128ce939edca70d5fb2926d260c8be1a5b813fdafd7797892c8f
MD5 f4ac2809305681148c64c2c1c2f0ab6c
BLAKE2b-256 0bc456e1d4388025abad898441af6420da49a31eaf171c0a9bb37328eac8cb21

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.10.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.10-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.10-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4662d818b61565012a8f13bc7ac1acf85be783f7fba1801ac73314826ecb4565
MD5 ea60c565296d977b0802334f8f7ef1af
BLAKE2b-256 bec8e122ed4769b1d06d752493f1b11d1c3ec63ec7814b48b5f0ce8b4ba29a10

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.10-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.10-cp314-cp314-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.10-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 4b5f7337d45204b01880b9cb56b1369ea148504a5cee6c50a73a60277ec0e785
MD5 980c11e906eda38c1582baf18973b09f
BLAKE2b-256 fc6f896c1661285d73768640dfd1b3f41c923b9e4509f439d79c6aedee818f13

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.10-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.10-cp314-cp314-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.10-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c7431dd53c90d971d27c43e1a01f04588b579d20ab4b2bcbf78b609a88de755b
MD5 f6a13f889c471ee655a73d9403175765
BLAKE2b-256 cc5efb3344b42106bf8a2846e2e539e90c0e46c7b6a8b2715d9deb35d01329e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.10-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.10-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.10-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e2fd58ef7a7523fd8f01c9a7869bbf748f9179f9e933697114bd292bf90c5c96
MD5 1658f8e9a8c6af5d1cd051b637bdc700
BLAKE2b-256 9e00496cc6b43237dd9626dfcc8527d2533ab7a2570e593137d9449af7ed2532

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.10-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.10-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.10-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 f45c0f12fbe1c6e80bddeb35ef6637ac69726cb5176a5e3e4d3758e0990eba3d
MD5 91140bdb4132d9f29c64922fd284c28f
BLAKE2b-256 006922b009e584767628999dbe084a477d6040fd470eac84c2e00b8e0d1174eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.10-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.10-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.10-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7e65cfc5c4bccd7d3e4a78f9b270ed2715e08a226d3d3e938cfe03d03fdadb79
MD5 26aab950bb62ccd25d2a778ab3e31459
BLAKE2b-256 88e1dcd5bc69bb7bdf66339e33ac39d546830660a4f6cd153a6eeeee58518ab2

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.10-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.10-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.10-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 737390f9bb67c9fc179ccea2efd46faaa90e53fc97624f1a340ef5d8a99ed468
MD5 966bfacbec1730913aa262070dbdd301
BLAKE2b-256 383e1044bb2f75d4c722dea263b880a806a4cf0622ed187f0a6f380a44e48540

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.10-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.10-cp312-cp312-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.10-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 56f021e7653bb7fca05e4508ede13d2f311ef8aa9b96a35e0685c297b1a596c4
MD5 6e29369e40a9eaec316846feb59c2e96
BLAKE2b-256 151818269af68de66e52178227b9b2e60ff8a219645cc3665079056a85228707

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.10-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.10-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for aiolibdatachannel-2026.5.10-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 40ddc8fb067e9e0ace43f1bdd5ac09a3fdea5ca884d3772b8ff9aba42bfc4dca
MD5 5324a77d6a63885216d281884d2c705f
BLAKE2b-256 1776cbe21a286c1feb3cf99bd0dbdd80a07e28dbcbe447206df7acc58ada963c

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiolibdatachannel-2026.5.10-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