symqtt
Blocking MQTT 3.1.1 / 5.0 client. No async runtime.
TCP/TLS live in symqtt-transport. Packet codec is symqtt-codec.
Why this crate
Most Rust MQTT clients sit on Tokio or C bindings. This crate is for sync apps, CLIs, and anything that should not pull an async runtime.
- Blocking I/O on the caller thread
ClientisSend + Sync(notClone; uniquely owns one connection)- 2–3 OS threads per connection
- Depends on
bytes,log,smallvec,thiserror, andsymqtt-codec
If you already run Tokio, use rumqttc.
Thread model
- Caller thread(s): encode and write. Concurrent calls are serialized by an internal mutex.
- Read thread: decode inbound packets, complete ACK tokens, invoke
InboundHandler. - Keepalive thread: PINGREQ when idle; drop the connection if PINGRESP times out.
Features
- MQTT 3.1.1 and 5.0
- QoS 0 / 1 / 2
- Session state that survives reconnect (inflight retransmission)
- MQTT 5.0: topic alias, enhanced auth, reason codes, server properties
- Last Will and Testament
- Pluggable
Transport
Quick start
[]
= "0.1"
= "0.1"
= "1"
use Duration;
use Bytes;
use ;
use TcpTransport;
;
MQTT 5.0 uses SubscribeFilter, message properties, and a reason code on disconnect. v5 ACK tokens return Ok even when the broker rejects the request — check ReasonCode::is_success on the returned code(s). Examples: examples/v3/, examples/v5/.
Reconnect
Session outlives Client. Keep the same session across reconnects so QoS 1/2 inflight is retransmitted with DUP=1.
let session = new;
loop
Custom transport
split() must yield independent halves. Ready-made TCP/TLS: symqtt-transport.
Logging
Uses the log crate. No output unless you install a backend.
RUST_LOG=symqtt=debug
License
Licensed under Apache License, Version 2.0.