{"id":15063412,"url":"https://github.com/jcksnvllxr80/mqtt_example","last_synced_at":"2026-01-02T14:36:14.117Z","repository":{"id":256950065,"uuid":"856574779","full_name":"jcksnvllxr80/mqtt_example","owner":"jcksnvllxr80","description":"mqtt example in go, rust, and python","archived":false,"fork":false,"pushed_at":"2024-09-13T12:56:14.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-22T06:25:43.297Z","etag":null,"topics":["docker","go","mqtt","python","rust"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcksnvllxr80.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-12T20:10:27.000Z","updated_at":"2024-09-13T12:56:18.000Z","dependencies_parsed_at":"2024-09-14T03:39:47.953Z","dependency_job_id":null,"html_url":"https://github.com/jcksnvllxr80/mqtt_example","commit_stats":null,"previous_names":["jcksnvllxr80/mqtt_example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcksnvllxr80%2Fmqtt_example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcksnvllxr80%2Fmqtt_example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcksnvllxr80%2Fmqtt_example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcksnvllxr80%2Fmqtt_example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcksnvllxr80","download_url":"https://codeload.github.com/jcksnvllxr80/mqtt_example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243761839,"owners_count":20343968,"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":["docker","go","mqtt","python","rust"],"created_at":"2024-09-24T23:56:31.373Z","updated_at":"2026-01-02T14:36:14.112Z","avatar_url":"https://github.com/jcksnvllxr80.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MQTT broker with producer/consumer client\n\nMQTT example. \n* The broker is MQTT and runs in a container (using docker-compose).  \n* The client application contains a producer and multiple consumers  \n  * Permanent (consuming all the time)\n  * Delayed (Consumes after the producer has finished plus a short delay)\n* The client application sends 5 messages to a topic `\u003clang\u003e/mqtt`  \n  * the messages are sent with the retain flag set true (`retain=True`)\n\nNOTE: **mqtt only holds the last message to a given topic so if clients are offline for an extended period, \nthey will likely lose messages.**\n\n## python output\n\nNOTE: when installing the paho-mqtt package, make sure to use `paho-mqtt\u003c2.0`. 2.0 and up made changes that dont work with this client code in this example.\n\n```text\nCleared retained messages on topic `python/mqtt`\nConnected to MQTT Broker with client ID: client-642!\nStopped network loop after clearing retained messages.\nStarting permanent listener...\nStarting to publish messages...\nConnected to MQTT Broker with client ID: listener-client-31!\nConnected to MQTT Broker with client ID: client-642!\nSend `message: 1` to topic `python/mqtt`\nPermanent Listener Received `message: 1` from `python/mqtt` topic\nSend `message: 2` to topic `python/mqtt`\nPermanent Listener Received `message: 2` from `python/mqtt` topic\nSend `message: 3` to topic `python/mqtt`\nPermanent Listener Received `message: 3` from `python/mqtt` topic\nSend `message: 4` to topic `python/mqtt`\nPermanent Listener Received `message: 4` from `python/mqtt` topic\nSend `message: 5` to topic `python/mqtt`\nStopped publishing messages.\nPermanent Listener Received `message: 5` from `python/mqtt` topic\nStopped network loop after publishing.\n---- Simulating an offline service by sending messages first and then receiving later ----\nWaiting 3 seconds before subscribing...\nStarting network loop for receiving messages...\nDelayed Subscriber Received `message: 5` from `python/mqtt` topic\nStopped network loop after receiving messages.\n\nProcess finished with exit code 0\n```\n\n## rust output \n\n```text\nStarting the permanent consumer...\nPermanent consumer subscribed to `rust/mqtt`\nPermanent consumer is ready\nPermanent consumer setup completed.\nStarting the producer...\nStarting to publish messages...\nPublishing `message: 1` to topic `rust/mqtt`\nPermanent consumer received `message: 1` from `rust/mqtt` topic\nPublishing `message: 2` to topic `rust/mqtt`\nPermanent consumer received `message: 2` from `rust/mqtt` topic\nPublishing `message: 3` to topic `rust/mqtt`\nPermanent consumer received `message: 3` from `rust/mqtt` topic\nPublishing `message: 4` to topic `rust/mqtt`\nPermanent consumer received `message: 4` from `rust/mqtt` topic\nPublishing `message: 5` to topic `rust/mqtt`\nPermanent consumer received `message: 5` from `rust/mqtt` topic\nStopped publishing messages.\nWaiting 3 seconds before starting the delayed consumer...\nDelayed consumer subscribed to `rust/mqtt`\nDelayed consumer received `message: 5` from `rust/mqtt` topic\n```\n\n## go output\n\n```text\nStarting the permanent consumer...\npermanent-consumer-1192 connected to broker\npermanent-consumer-1192 subscribed to `go/mqtt`\nPermanent consumer setup completed.\nStarting the producer...\nproducer-9233 connected to broker\nStarting to publish messages...\nproducer-9233 publishing `message: 1` to topic `go/mqtt`\npermanent-consumer-1192 received `message: 1` from `go/mqtt` topic\nproducer-9233 publishing `message: 2` to topic `go/mqtt`\npermanent-consumer-1192 received `message: 2` from `go/mqtt` topic\nproducer-9233 publishing `message: 3` to topic `go/mqtt`\npermanent-consumer-1192 received `message: 3` from `go/mqtt` topic\nproducer-9233 publishing `message: 4` to topic `go/mqtt`\npermanent-consumer-1192 received `message: 4` from `go/mqtt` topic\nproducer-9233 publishing `message: 5` to topic `go/mqtt`\npermanent-consumer-1192 received `message: 5` from `go/mqtt` topic\nproducer-9233 stopped publishing messages.\nWaiting 3 seconds before starting the delayed consumer...\ndelayed-consumer-36 connected to broker\ndelayed-consumer-36 subscribed to `go/mqtt`\ndelayed-consumer-36 received `message: 5` from `go/mqtt` topic\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcksnvllxr80%2Fmqtt_example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcksnvllxr80%2Fmqtt_example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcksnvllxr80%2Fmqtt_example/lists"}