{"id":26107047,"url":"https://github.com/misaghmomenib/mqtt-messaging-python","last_synced_at":"2026-05-02T11:39:17.786Z","repository":{"id":281513443,"uuid":"945497581","full_name":"MisaghMomeniB/MQTT-Messaging-Python","owner":"MisaghMomeniB","description":"In This Repository, I Wrote a Simple Messaging System Using Mqtt That You Can Easily Send and Receive Messages.","archived":false,"fork":false,"pushed_at":"2025-03-09T15:53:48.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-09T16:30:51.880Z","etag":null,"topics":["git","mqtt","mqtt-broker","mqtt-server","open-source","python"],"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/MisaghMomeniB.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":"2025-03-09T15:09:36.000Z","updated_at":"2025-03-09T15:55:06.000Z","dependencies_parsed_at":"2025-03-09T16:41:02.997Z","dependency_job_id":null,"html_url":"https://github.com/MisaghMomeniB/MQTT-Messaging-Python","commit_stats":null,"previous_names":["misaghmomenib/mqtt-messaging-python"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MisaghMomeniB%2FMQTT-Messaging-Python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MisaghMomeniB%2FMQTT-Messaging-Python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MisaghMomeniB%2FMQTT-Messaging-Python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MisaghMomeniB%2FMQTT-Messaging-Python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MisaghMomeniB","download_url":"https://codeload.github.com/MisaghMomeniB/MQTT-Messaging-Python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242762737,"owners_count":20181266,"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":["git","mqtt","mqtt-broker","mqtt-server","open-source","python"],"created_at":"2025-03-09T22:42:58.811Z","updated_at":"2026-05-02T11:39:17.780Z","avatar_url":"https://github.com/MisaghMomeniB.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📡 MQTT Messaging (Python)\n\nA lightweight and configurable **MQTT pub/sub messaging tool** in Python. Built using the popular **Paho MQTT client**, it’s designed for rapid prototyping of IoT messaging, automation workflows, or testing pub/sub systems.\n\n---\n\n## 📋 Table of Contents\n\n1. [Overview](#overview)  \n2. [Features](#features)  \n3. [Prerequisites](#prerequisites)  \n4. [Installation](#installation)  \n5. [Usage Examples](#usage-examples)  \n6. [Code Structure](#code-structure)  \n7. [Security \u0026 Tips](#security--tips)  \n8. [Contributing](#contributing)  \n9. [License](#license)\n\n---\n\n## 💡 Overview\n\nThis project wraps basic MQTT functionality—**connecting**, **publishing**, and **subscribing**—into a reusable Python tool. Leveraging the **Paho MQTT client**, it supports features essential for IoT messaging such as QoS control, TLS settings, and auto-reconnect logic :contentReference[oaicite:1]{index=1}.\n\n---\n\n## ✅ Features\n\n- 🔌 Connect to MQTT brokers using TCP or WebSocket  \n- 📢 Publish messages with customizable **QoS** and optional retain flag  \n- 📩 Subscribe to topics with callback handling  \n- 🔁 Auto-reconnect for improved reliability  \n- 🌐 TLS/SSL support \u0026 optional username/password authentication :contentReference[oaicite:2]{index=2}  \n- 📄 Simple CLI interface or importable module\n\n---\n\n## 🛠️ Prerequisites\n\n- Python **3.7+**  \n- MQTT broker access (e.g., Mosquitto, EMQX, HiveMQ, or cloud broker)  \n- Required package:\n\n```bash\npip install paho-mqtt\n````\n\n---\n\n## ⚙️ Installation\n\n```bash\ngit clone https://github.com/MisaghMomeniB/MQTT-Messaging-Python.git\ncd MQTT-Messaging-Python\npip install -r requirements.txt  # or 'pip install paho-mqtt'\n```\n\n---\n\n## 🚀 Usage Examples\n\n### 🔗 Connect \u0026 Subscribe\n\n```python\nfrom mqtt_messaging import MQTTPublisher, MQTTSubscriber\n\n# Subscribe example\nsub = MQTTSubscriber(broker='broker.emqx.io', topic='my/topic', port=1883)\nsub.connect()\nsub.subscribe()\nsub.loop_forever()  # listens indefinitely\n```\n\n### 📤 Publish Messages\n\n```python\npub = MQTTPublisher(broker='broker.emqx.io', port=1883, qos=1, retain=True)\npub.connect()\npub.publish('my/topic', 'Hello MQTT! 😊')\npub.disconnect()\n```\n\n### 📦 CLI Example\n\n```bash\npython mqtt_tool.py --mode pub --topic my/topic --message \"testing 123\" --qos 1\npython mqtt_tool.py --mode sub --topic my/topic --broker demo.mosquitto.org\n```\n\n---\n\n## 📁 Code Structure\n\n```\nMQTT-Messaging-Python/\n├── mqtt_tool.py          # CLI wrapper\n├── mqtt_messaging.py     # Core publish \u0026 subscribe classes\n├── requirements.txt      # Dependencies\n└── README.md             # This file\n```\n\n* `MQTTPublisher`: MQTT client for publishing\n* `MQTTSubscriber`: MQTT client for subscribing with callback support\n* CLI script parses basic flags and invokes classes\n\n---\n\n## 🔒 Security \u0026 Tips\n\n* ⚙️ Use `client.tls_set(...)` and `username_pw_set()` for secure, authenticated connections ([github.com][1], [emqx.com][2], [hivemq.com][3])\n* Auto-reconnect ensures resilience in unstable networks ([emqx.com][2])\n* Set **QoS** appropriately (`0`, `1`, `2`) for guaranteed delivery or low latency\n* Consider using Last Will \u0026 Testament (LWT) for failure messaging in IoT deployments\n\n---\n\n## 🤝 Contributing\n\nEnhancements are welcome! Suggestions include:\n\n* 🔁 Support for batch publishing or message queues\n* 📊 Add message logging or replay functionality\n* 🌐 Support for MQTT v5 features: message expiry, shared subscriptions\n* 🧪 Add unit tests with pytest/mock\n* 📦 Package as a pip-installable library\n\nTo contribute:\n\n1. Fork the repository\n2. Create a branch (`feature/...`)\n3. Implement tests and document changes\n4. Open a Pull Request\n\n---\n\n## 📄 License\n\nReleased under the **MIT License**. See `LICENSE` for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisaghmomenib%2Fmqtt-messaging-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmisaghmomenib%2Fmqtt-messaging-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisaghmomenib%2Fmqtt-messaging-python/lists"}