Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

MQTTium

MQTTium is a reliable, async-native MQTT client for modern Python.

It combines a synchronous protocol engine with an asyncio API, bounded backpressure, durable inflight persistence, explicit delivery receipts, and complete MQTT QoS state machines.

Status: alpha (0.1.0a2). The implementation is extensively tested, but the public API may still change before the first stable release.

Features

  • MQTT 3.1.1 and MQTT 5;
  • QoS 0, 1 and 2 with one authoritative protocol state machine;
  • TCP, TLS, WebSocket and Unix transports;
  • reconnect and session replay;
  • bounded callback and async-iterator delivery;
  • manual acknowledgement;
  • in-memory and SQLite inflight persistence;
  • aggregate publish_many() with bounded memory and measured throughput gains;
  • an additive Paho VERSION2 compatibility façade, isolated from the native API;
  • inline type information for type checkers.

Python 3.11–3.14 is supported. MQTTium is licensed under Apache-2.0.

Installation

python -m pip install mqttium

To work on the unreleased development version:

git clone https://github.com/yoch/mqttium.git
cd mqttium
python -m pip install -e ".[dev,fuzz,release]"

Quick start

import asyncio

from mqttium.api import AsyncClient


async def main() -> None:
    client = AsyncClient("demo-client")
    await client.connect("127.0.0.1", 1883)
    await client.subscribe("demo/#")

    receipt = await client.publish("demo/hello", b"world", qos=1)
    await receipt.wait()

    await client.disconnect()


asyncio.run(main())

Batched publishing

publish_many() consumes iterables in bounded chunks and returns one aggregate receipt rather than creating one task or event per message:

from mqttium.api import PublishMessage

batch = await client.publish_many(
    PublishMessage("telemetry/device-1", payload, qos=1)
    for payload in payloads
)
await batch.wait()

The retained paired A/B benchmark measured publisher-throughput geomean improvements of 36.9% for QoS 0, 15.9% for QoS 1, and 7.0% for QoS 2 against equivalent individual publishing pipelines on the validated source tree. Benchmark methodology and limitations are documented in docs/BENCHMARKING.md.

Bounded memory

Every queue that can grow with application load is bounded by default, so a producer that outruns its broker is slowed down rather than allowed to exhaust the process:

client = AsyncClient(
    max_pending_outbound_messages=10_000,   # unfinished QoS 1/2 publications
    max_pending_outbound_bytes=64 * 1024**2,  # their logical topic+payload+properties
    max_pending_delivery_bytes=64 * 1024**2,  # inbound messages awaiting a consumer
    publish_backpressure="wait",            # or "error" to refuse immediately
)

publish() waits for capacity by default and raises FlowControlError under publish_backpressure="error" or with nowait=True. A refusal is atomic: no packet identifier is allocated and no store record is written. Pass None for any limit to restore unbounded queueing.

These defaults are new in 0.1.0a2; before them a QoS 1/2 producer could queue until the 65 535 packet-identifier space was exhausted. See docs/MIGRATION.md.

Validation

The release gates include:

  • more than 300 unit tests;
  • Mosquitto integration tests on Python 3.11, 3.12, 3.13 and 3.14;
  • deterministic and Hypothesis-based fuzzing;
  • Ruff formatting and linting;
  • mypy validation and a PEP 561 py.typed marker;
  • an 80% coverage gate;
  • wheel, source-distribution and isolated-install validation;
  • delivery, persistence, TCP, TLS and WAN-profile benchmarks.

Documentation

Contributing and security

See CONTRIBUTING.md. Report vulnerabilities through the private process described in SECURITY.md.

Download files

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

Source Distribution

mqttium-0.1.0a2.tar.gz (174.6 kB view details)

Uploaded Source

Built Distribution

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

mqttium-0.1.0a2-py3-none-any.whl (82.9 kB view details)

Uploaded Python 3

File details

Details for the file mqttium-0.1.0a2.tar.gz.

File metadata

  • Download URL: mqttium-0.1.0a2.tar.gz
  • Upload date:
  • Size: 174.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mqttium-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 509d394a34fc14f5cc2eb2a041d60a0d54e56e4eb77d425477e9d92ddb99e2d1
MD5 8c3ee72e35d0a26cee2dc44c1c1957db
BLAKE2b-256 df2da64525583410ab9c5552edd7555f21f1014e8a61433a1e895a56fb37e5ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for mqttium-0.1.0a2.tar.gz:

Publisher: publish.yml on yoch/mqttium

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

File details

Details for the file mqttium-0.1.0a2-py3-none-any.whl.

File metadata

  • Download URL: mqttium-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 82.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mqttium-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 4b340ce27a63238572ec6b84f43f50493ae2ec747a9f323394da98fdd944b825
MD5 7145ec170681b11f7fa3a6fbdae20a35
BLAKE2b-256 0032b0639849a5a81ad6979d5b3418d16e561d3b0ee2cdb0557e1b3d510dc465

See more details on using hashes here.

Provenance

The following attestation bundles were made for mqttium-0.1.0a2-py3-none-any.whl:

Publisher: publish.yml on yoch/mqttium

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