{"id":15063436,"url":"https://github.com/iwanbk/nyamuk","last_synced_at":"2025-04-10T11:09:23.324Z","repository":{"id":2674579,"uuid":"3666519","full_name":"iwanbk/nyamuk","owner":"iwanbk","description":"Python MQTT Client Library Based on libmosquitto","archived":false,"fork":false,"pushed_at":"2018-11-20T22:02:31.000Z","size":177,"stargazers_count":77,"open_issues_count":1,"forks_count":23,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-21T21:45:00.273Z","etag":null,"topics":["m2m","mqtt","mqtt-client","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iwanbk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-09T02:00:08.000Z","updated_at":"2024-10-13T19:39:19.000Z","dependencies_parsed_at":"2022-09-10T04:23:02.752Z","dependency_job_id":null,"html_url":"https://github.com/iwanbk/nyamuk","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwanbk%2Fnyamuk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwanbk%2Fnyamuk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwanbk%2Fnyamuk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwanbk%2Fnyamuk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iwanbk","download_url":"https://codeload.github.com/iwanbk/nyamuk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248008629,"owners_count":21032556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["m2m","mqtt","mqtt-client","python"],"created_at":"2024-09-24T23:56:59.865Z","updated_at":"2025-04-10T11:09:23.308Z","avatar_url":"https://github.com/iwanbk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nNyamuk\n======\n\nNyamuk is a python MQTT library, originally based on libmosquitto.  \nIt implements both 3.1 and 3.1.1 versions of MQTT protocol.  \nCurrently only supporting python 2.7\n\nFeatures\n--------\n\n* [x] MQTT v3.1\n* [x] MQTT v3.1.1\n* [x] SSL\n* [x] Qos 0, 1 \u0026 2 support\n* [ ] docstring \u0026 documentation\n* [ ] python3 support\n* [ ] advanced logging\n\nInstall\n-------\n\nfrom sources:\n```\n$\u003e python setup.py install\n```\n\nusing pypi package:\n```\n$\u003e pip install nyamuk\n```\n\nExample\n-------\n\nPublishing a message with Qos 1 (with MQTT v3.1.1)\n```python\nimport sys\nfrom nyamuk import *\n\ndef nloop(client):\n    client.packet_write()     # flush write buffer (messages sent to MQTT server)\n    client.loop()             # fill read buffer   (enqueue received messages)\n    return client.pop_event() # return 1st received message (dequeued)\n\nclient = Nyamuk(\"test_nyamuk\", server=\"test.mosquitto.org\")\nret = client.connect(version=4)\nret = nloop(client) # ret should be EventConnack object\nif not isinstance(ret, EventConnack) or ret.ret_code != 0:\n    print 'connection failed'; sys.exit(1)\n\nclient.publish('foo/bar', 'this is a test', qos=1)\nret = nloop(client) # ret should be EventPuback\n\nclient.disconnect()\n```\n\nSubscribing a topic\n```python\nimport sys\nfrom nyamuk import *\n\ndef nloop(client):\n    client.packet_write()     # flush write buffer (messages sent to MQTT server)\n    client.loop()             # fill read buffer   (enqueue received messages)\n    return client.pop_event() # return 1st received message (dequeued)\n\nclient = Nyamuk(\"test_nyamuk\", server=\"test.mosquitto.org\")\nret = client.connect(version=4)\nret = nloop(client) # ret should be EventConnack object\nif not isinstance(ret, EventConnack) or ret.ret_code != 0:\n    print 'connection failed'; sys.exit(1)\n\nclient.subscribe('foo/bar', qos=1)\nret = nloop(client)\nif not isinstance(ret, EventSuback):\n    print 'SUBACK not received'; sys.exit(2)\nprint 'granted qos is', ret.granted_qos[0]\n\ntry:\n    while True:\n        evt = nloop(client)\n        if isinstance(evt, EventPublish):\n            print 'we received a message: {0} (topic= {1})'.format(evt.msg.payload, evt.msg.topic)\n            \n            # received message is either qos 0 or 1\n            # in case of qos 1, we must send back PUBACK message with same packet-id\n            if evt.msg.qos == 1:\n                client.puback(evt.msg.mid)\n\nexcept KeyboardInterrupt:\n    pass\n\nclient.disconnect()\n```\n\n\nAuthors\n-------\n\nOriginal creator: Iwan B. Kusnanto  \nCurrent maintainer: Guillaume Bour\n\nLicense\n-------\n\nNyamuk is distributed under BSD license\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwanbk%2Fnyamuk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiwanbk%2Fnyamuk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwanbk%2Fnyamuk/lists"}