rumqttc
A high-level, robust async MQTT client for Rust built on tokio.
Repository Health
Technical Analysis
rumqttc is the client crate of the rumqtt project, a pure-Rust implementation of the MQTT standard focused on being simple, robust, and performant. It provides a high-level, easy-to-use MQTT 3.1.1 and 5 client that connects to any MQTT broker to publish and subscribe to topics with configurable quality-of-service levels.
Built on tokio, rumqttc exposes a driver-style event loop where you enqueue publish/subscribe requests and poll the connection for incoming packets and acknowledgements. It handles connection management, keep-alive, automatic reconnection, TLS, and backpressure, making it a common choice for IoT devices and services written in Rust.
What You Get
- A high-level MQTT 3.1.1 and MQTT 5 client with publish, subscribe, and unsubscribe APIs
- A tokio-based async event loop that manages connection, keep-alive, and automatic reconnection
- Configurable quality-of-service (QoS 0/1/2) and last-will/retained message support
- TLS support and both async and a synchronous client wrapper for non-async callers
Common Use Cases
- Connecting an IoT device or gateway written in Rust to an MQTT broker
- Publishing telemetry from edge services and subscribing to command topics
- Bridging MQTT messages into other systems from a Rust backend
- Building resilient pub/sub messaging that survives network interruptions via automatic reconnection
Under The Hood
Architecture - rumqttc lives in the rumqttc/ crate of the rumqtt Cargo workspace (alongside the rumqttd broker). Its design separates a lightweight AsyncClient handle, which pushes Requests onto a channel, from an EventLoop that owns the network connection and MQTT state machine. Calling eventloop.poll() progresses the connection: it writes queued requests, reads incoming packets, handles keep-alive pings, and surfaces Events (incoming publishes, acks, connection state) to the caller. The MQTT packet codec is shared with the broker via the mqttbytes module.
Tech Stack - Written almost entirely in Rust (99%) on tokio for async I/O, with optional TLS backends (rustls / native-tls) behind feature flags. A synchronous Client wraps the async client for callers not using an async runtime.
Code Quality - As a mature, widely used project (800+ commits, 100+ contributors, 6.9M downloads) rumqttc maintains CI, Coveralls coverage reporting, and a suite of tests around the event loop and packet handling. The explicit request/poll model makes state transitions testable and avoids hidden background tasks.
API Design - The event-loop model is the crate’s defining ergonomic choice: it is very robust and gives callers full control over polling and backpressure, but it is less push-based than some MQTT libraries, so newcomers must learn to drive the loop. Once understood, the API is compact — create a client, spawn a poll loop, and issue publish/subscribe calls — and the docs plus examples cover the common patterns well.