An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# mqtt5

PyPI downloads PyPI version Supported Python versions

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.