https://github.com/empicano/mqtt5
The MQTTv5 protocol for Python written in Rust
https://github.com/empicano/mqtt5
internet-of-things iot mqtt mqtt5 networking protocol pubsub python rust sans-io
Last synced: 2 months ago
JSON representation
The MQTTv5 protocol for Python written in Rust
- Host: GitHub
- URL: https://github.com/empicano/mqtt5
- Owner: empicano
- License: bsd-3-clause
- Created: 2025-07-08T18:00:00.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2026-03-22T23:08:45.000Z (3 months ago)
- Last Synced: 2026-03-23T17:41:32.315Z (3 months ago)
- Topics: internet-of-things, iot, mqtt, mqtt5, networking, protocol, pubsub, python, rust, sans-io
- Language: Rust
- Homepage:
- Size: 306 KB
- Stars: 16
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# mqtt5
A [sans-I/O](https://sans-io.readthedocs.io/how-to-sans-io.html#what-is-an-i-o-free-protocol-implementation) implementation of the MQTTv5 protocol for Python, written in Rust. Serialization is ~5x faster and deserialization ~20x faster than comparable Python code (benchmarked against [mqttproto](https://github.com/agronholm/mqttproto)).
Reading/Writing a QoS=1 Publish packet with 256 bytes payload.
**Serialize a packet to bytes**
```py
import mqtt5
packet = mqtt5.ConnectPacket(client_id="Bulbasaur")
data = packet.write()
```
**Deserialize a packet from bytes**
```py
import mqtt5
buffer = memoryview(b"\x20\x03\x00\x00\x00")
packet, nbytes = mqtt5.read(buffer)
```
## Key features
- Complete MQTTv5 support (user properties, QoS, topic aliases, flow control, ...)
- Packets are serialized to minimal wire format
- Strict validation on both outgoing and incoming packets
- Fully type-annotated
## Installation
```bash
pip install mqtt5
```
Note that mqtt5 implements only the low-level packet de/serialization. If you're looking for a complete MQTT client, check out [aiomqtt](https://github.com/empicano/aiomqtt).
## Documentation
See the [stub file](https://github.com/empicano/mqtt5/blob/main/mqtt5/mqtt5.pyi) for an API reference and the [MQTTv5 specification](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html) for details about the de/serialization.
## Versioning
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Changelog
See [CHANGELOG.md](https://github.com/empicano/mqtt5/blob/main/CHANGELOG.md), which follows the principles of [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
## Acknowledgments
I've learned a lot from Alex Grönholm's [mqttproto](https://github.com/agronholm/mqttproto), which is an excellent pure-Python MQTTv5 protocol implementation.