skillfed

gmqtt

Client for MQTT protocol

gmqtt v0.7.0 159.4K downloads/30d#10,698 on PyPI450
Permissive license MIT Active released

What it is and what it does

gmqtt is a pure-Python async MQTT client library built on asyncio for connecting to MQTT brokers and exchanging messages. It implements both MQTT 5.0 (default) and 3.1.1 protocols, with automatic downgrade if a broker does not support version 5.0. The client handles subscriptions, message publishing with configurable QoS levels, authentication, and automatic reconnection with tunable retry behavior.

The library is callback-driven: you define handlers for connect, message receipt, disconnect, and subscribe events, then await the main connection loop. It supports MQTT 5.0 properties (session expiry, maximum packet size, user properties, content type, message expiry) and allows both synchronous and asynchronous message handlers. No external dependencies are required beyond Python's standard asyncio, making it lightweight and straightforward to integrate into async applications.

Use it for:

  • Build IoT device clients that publish sensor data and subscribe to control commands over MQTT.
  • Create real-time message brokers or gateways that relay MQTT traffic between multiple topics or brokers.
  • Implement monitoring dashboards that subscribe to device telemetry and display live updates.
  • Develop async Python services that need to communicate via MQTT without blocking the event loop.
  • Test MQTT broker behavior and message flow by scripting client interactions in Python.

Worth the install?

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

gmqtt is an async Python MQTT client that connects to MQTT brokers, publishes and subscribes to topics, and handles message delivery with support for MQTT 5.0 and 3.1.1 protocols.

Yes. gmqtt is a solid, actively maintained MQTT client with zero dependencies, permissive licensing, and broad protocol support. Install it if you need async MQTT connectivity in Python and are comfortable with callback-based event handling. The 630 days since last release is not a concern given the active repository and recent commits; the library is stable rather than abandoned.

Install

gmqtt on PyPI

pip

pip install gmqtt

uv

uv add gmqtt

poetry

poetry add gmqtt

Installing gmqtt

Before you install

Low friction: pure Python wheel with no runtime dependencies. Actively maintained with recent commits and a stable release history since 2018.

License in practice

MIT license is permissive; you can use, modify, and distribute gmqtt freely in commercial and open-source projects with minimal restrictions.

Quickstart

pip install gmqtt

import asyncio
from gmqtt import Client as MQTTClient

async def main():
    client = MQTTClient("client-id")
    client.on_message = lambda c, t, p, q, pr: print(p)
    await client.connect("mqtt.broker.host")
    client.subscribe("topic/name")
    await asyncio.sleep(10)
    await client.disconnect()

asyncio.run(main())

Requires Python 3.5 or later and an accessible MQTT broker at connection time.

Verify before relying

  • Whether uvloop integration (mentioned in docs) provides measurable performance gains for typical workloads.
  • Behavior and compatibility with brokers that do not support MQTT 5.0 downgrade negotiation.
  • Performance characteristics under high message throughput or with many concurrent subscriptions.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.5)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 630 days since the last release
Last repo commit
First released
Downloads 159,368/month — #10,698 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: gmqtt-0.7.0-py3-none-any.whl

Keywords: Gurtam, MQTT, client.

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonTopic :: Software Development :: Libraries :: Python Modules

Tags

mqtt client python asyncmqtt publish subscribemqtt 5.0 protocolasyncio mqtt brokermqtt message handlingmqtt reconnectmqtt qos delivery
mqttasyncioiot

More Python Modules packages