Registry / http-networking / gmqtt
library0.7.0pypypi✓ verified 83d ago

Asynchronous MQTT client for Python (3.5+) using asyncio. Supports QoS 0/1/2, TLS, WebSocket, and MQTT v5.0. Maintained by Wialon. Current version 0.7.0, with irregular releases (last in 2023).

pip install gmqtt
INSTALL
IMPORT
SIG · GMQTT
G
gmqtt
http-networkingpythonv0.7.0
Install
1.5s avg
Import
222ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.242s · 18MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.202s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
from gmqtt import Client
Main class for creating MQTT clients.
Message
from gmqtt import Message
Represents an MQTT message.

Basic connect, subscribe, publish with authentication.

import asyncio import os from gmqtt import Client as MQTTClient async def main(): client = MQTTClient("client_id") client.set_auth_credentials(os.environ.get('MQTT_USER', ''), os.environ.get('MQTT_PASS', '')) # Set callbacks def on_message(client, topic, payload, qos, properties): print(f"Received: {topic} -> {payload}") client.on_message = on_message await client.connect('localhost', 1883) client.subscribe('test/topic') client.publish('test/topic', 'hello') await asyncio.sleep(2) await client.disconnect() if __name__ == '__main__': asyncio.run(main())
Debug
Known issues
breakingIn version 0.7.0, `on_message` signature changed: new parameter `properties` added. Old code with `client.on_message = on_message(client, topic, payload, qos)` will raise TypeError.
fix
Update callback to accept 5 arguments: client, topic, payload, qos, properties.
affects: >=0.7.0
gotchaUsing `Client` class without calling `set_auth_credentials` when broker requires auth will silently disconnect. No error is raised until publish/subscribe fails.
fix
Always call `set_auth_credentials(username, password)` if broker expects authentication.
affects: all
gotchaConnecting with the same `client_id` to a broker that has session present can cause the previous session to be taken over. The client might not receive messages until reconnection completes.
fix
Use unique client IDs or set `clean_session=True` when connecting.
affects: all
Errors
Common errors & fixes
TypeError: on_message() takes 4 positional arguments but 5 were given
Callback signature expects 4 arguments but gmqtt 0.7.0 passes 5 (added 'properties').
fix
Update callback to `def on_message(client, topic, payload, qos, properties): ...`.
AttributeError: 'Client' object has no attribute '_on_connect'
Trying to monkey-patch internal attribute; gmqtt uses public callback `on_connect` with underscore prefix removed.
fix
Use `client.on_connect = lambda client, flags, rc, properties: ...` (5 args).
ModuleNotFoundError: No module named 'gmqtt'
Not installed or installed in a different environment.
fix
Run `pip install gmqtt` in the correct Python environment.
Upgrade
Version history
0.7.0latest on PyPI · released Nov 22, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
32 hits · last 30 days
node
30
OpenAI (training)
1
Resources
gmqtt — pip install gmqtt · libregistry