{"id":23797,"library":"gmqtt","title":"gmqtt","description":"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).","status":"active","version":"0.7.0","language":"python","source_language":"en","source_url":"https://github.com/wialon/gmqtt","tags":["mqtt","asyncio","iot","messaging"],"install":[{"cmd":"pip install gmqtt","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"Main class for creating MQTT clients.","symbol":"Client","correct":"from gmqtt import Client"},{"note":"Represents an MQTT message.","symbol":"Message","correct":"from gmqtt import Message"}],"quickstart":{"code":"import asyncio\nimport os\nfrom gmqtt import Client as MQTTClient\n\nasync def main():\n    client = MQTTClient(\"client_id\")\n    client.set_auth_credentials(os.environ.get('MQTT_USER', ''), os.environ.get('MQTT_PASS', ''))\n    # Set callbacks\n    def on_message(client, topic, payload, qos, properties):\n        print(f\"Received: {topic} -> {payload}\")\n    client.on_message = on_message\n    await client.connect('localhost', 1883)\n    client.subscribe('test/topic')\n    client.publish('test/topic', 'hello')\n    await asyncio.sleep(2)\n    await client.disconnect()\n\nif __name__ == '__main__':\n    asyncio.run(main())","lang":"python","description":"Basic connect, subscribe, publish with authentication."},"warnings":[{"fix":"Update callback to accept 5 arguments: client, topic, payload, qos, properties.","message":"In 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.","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Always call `set_auth_credentials(username, password)` if broker expects authentication.","message":"Using `Client` class without calling `set_auth_credentials` when broker requires auth will silently disconnect. No error is raised until publish/subscribe fails.","severity":"gotcha","affected_versions":"all"},{"fix":"Use unique client IDs or set `clean_session=True` when connecting.","message":"Connecting 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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.7.0':23 '0/1/2':12 '2023':29 '3.5':7 'asynchron':2 'asyncio':9,31 'client':4 'current':21 'gmqtt':1 'iot':32 'irregular':25 'last':27 'maintain':18 'messag':33 'mqtt':3,16,30 'python':6 'qos':11 'releas':26 'support':10 'tls':13 'use':8 'v5.0':17 'version':22 'websocket':14 'wialon':20","created_at":"2026-05-01T08:09:41.229871+00:00","updated_at":"2026-05-01T08:09:41.229871+00:00","problems":[{"fix":"Update callback to `def on_message(client, topic, payload, qos, properties): ...`.","cause":"Callback signature expects 4 arguments but gmqtt 0.7.0 passes 5 (added 'properties').","error":"TypeError: on_message() takes 4 positional arguments but 5 were given"},{"fix":"Use `client.on_connect = lambda client, flags, rc, properties: ...` (5 args).","cause":"Trying to monkey-patch internal attribute; gmqtt uses public callback `on_connect` with underscore prefix removed.","error":"AttributeError: 'Client' object has no attribute '_on_connect'"},{"fix":"Run `pip install gmqtt` in the correct Python environment.","cause":"Not installed or installed in a different environment.","error":"ModuleNotFoundError: No module named 'gmqtt'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.7.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/wialon/gmqtt","docs":null,"changelog":null,"pypi":"https://pypi.org/project/gmqtt/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}