rumqttc
A pure rust MQTT client which strives to be robust, efficient and easy to use. This library is backed by an async (tokio) eventloop which handles all the robustness and and efficiency parts of MQTT but naturally fits into both sync and async worlds as we'll see
Let's jump into examples right away
A simple synchronous publish and subscribe
use ;
use Duration;
use thread;
A simple asynchronous publish and subscribe
use ;
use ;
use Duration;
use Error;
async
Quick overview of features
- Eventloop orchestrates outgoing/incoming packets concurrently and hadles the state
- Pings the broker when necessary and detects client side half open connections as well
- Throttling of outgoing packets (todo)
- Queue size based flow control on outgoing packets
- Automatic reconnections by just continuing the
eventloop.poll()/connection.iter()
loop` - Natural backpressure to client APIs during bad network
- Immediate cancellation with
client.cancel()
In short, everything necessary to maintain a robust connection
NOTE: Looping on connection.iter()/eventloop.poll()
is necessary to
run the eventloop and make progress. It yields incoming and outgoing activity
notifications which allows customization as user sees fit.
IMPORTANT Blocking inside eventloop.poll()/eonnection.iter()
loop
will block connection progress
Since the eventloop is externally polled (with iter()/poll()
in a loop)
out side the library and Eventloop
is accessible, users can
- Distribute incoming messages based on topics
- Stop it when required
- Access internal state for use cases like graceful shutdown or to modify options before reconnection
License: Apache-2.0