skillfed

aiomqtt

The idiomatic asyncio MQTT client

aiomqtt v2.5.1 1.2M downloads/30d#4,284 on PyPI569
Permissive license Active released

What it is and what it does

aiomqtt is an asyncio wrapper around paho-mqtt that replaces callback-based MQTT programming with async/await patterns. Instead of registering on_publish, on_subscribe, and on_disconnect callbacks, you write linear async code using context managers and async iteration. It supports MQTT 5.0, 3.1.1, and 3.1, is fully type-hinted, and raises MqttError exceptions instead of returning numeric error codes.

The package is designed for developers building IoT applications, real-time data pipelines, or other systems that need to publish or subscribe to MQTT topics without blocking. It has been actively maintained since 2017, supports Python 3.8 through 3.13, and carries no known security vulnerabilities. The only gotcha is a Windows-specific event loop configuration requirement documented in the description.

Use it for:

  • Publish sensor readings to an MQTT broker from an asyncio application without blocking other concurrent tasks.
  • Subscribe to multiple MQTT topics and process incoming messages in an async for loop within a larger async application.
  • Build IoT gateways or data aggregators that need to handle many concurrent MQTT connections with clean async/await syntax.
  • Integrate MQTT messaging into async web frameworks or other asyncio-based services.
  • Replace callback-heavy paho-mqtt code with readable linear async code in new projects.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

An asyncio-native MQTT client that wraps paho-mqtt to provide async/await syntax for publishing and subscribing to MQTT brokers, supporting MQTT versions 5.0, 3.1.1, and 3.1.

Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and solves a real pain point—callback-based MQTT programming—with a clean async/await API. It is well-suited for any asyncio application that needs MQTT. The Windows event loop caveat is documented and straightforward to work around.

Install

aiomqtt on PyPI

pip

pip install aiomqtt

uv

uv add aiomqtt

poetry

poetry add aiomqtt

Installing aiomqtt

Before you install

Low friction: pure Python wheel with only paho-mqtt and typing-extensions as runtime dependencies. Active maintenance with recent commits and no known vulnerabilities.

License in practice

BSD 3-clause permissive license. The underlying paho-mqtt dependency is dual-licensed under BSD 3-clause and Eclipse Distribution License v1.0, both permissive.

Quickstart

pip install aiomqtt

import asyncio
from aiomqtt import Client

async def main():
    async with Client("test.mosquitto.org") as client:
        await client.publish("temperature/outside", payload=28.4)

asyncio.run(main())

On Windows with Python 3.8+, the default ProactorEventLoop does not support the add_reader method required by aiomqtt; you must switch to SelectorEventLoop before running.

Verify before relying

  • Whether the package handles reconnection and backpressure automatically or requires explicit handling in user code.
  • Performance characteristics and latency overhead compared to direct paho-mqtt usage.

Package facts

License not declared (permissive)
Python support supports the current Python release (<4.0,>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 2 — paho-mqtt, typing-extensions
Maintenance actively maintained — 162 days since the last release
Last repo commit
First released
Downloads 1,161,075/month — #4,284 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: aiomqtt-2.5.1-py3-none-any.whl

Keywords: asyncio, internet-of-things, iot, mqtt, mqttv5, paho-mqtt

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

asyncio mqtt clientasync mqtt publish subscribemqtt5 python asynciot messaging asynciomqtt broker client asyncpaho mqtt wrapper asyncionon-blocking mqtt
mqttasyncioiot

More Internet packages