#mqtt #async #client #io


An MQTT 3.1.1 client written in Rust, using async functions and tokio

11 releases

0.3.1 Sep 6, 2021
0.3.0 Sep 5, 2021
0.2.0 Feb 18, 2021
0.1.7 Oct 30, 2020
0.1.1 Jan 17, 2020
Download history 136/week @ 2023-07-21 119/week @ 2023-07-28 229/week @ 2023-08-04 437/week @ 2023-08-11 345/week @ 2023-08-18 663/week @ 2023-08-25 341/week @ 2023-09-01 566/week @ 2023-09-08 473/week @ 2023-09-15 349/week @ 2023-09-22 336/week @ 2023-09-29 726/week @ 2023-10-06 115/week @ 2023-10-13 211/week @ 2023-10-20 455/week @ 2023-10-27 235/week @ 2023-11-03

1,025 downloads per month
Used in 4 crates

MIT license

1.5K SLoC


An MQTT 3.1.1 client written in Rust, using async functions and tokio.

Pull requests and Github issues welcome!

To run automated tests

Simply run cargo test.

The integration tests require an MQTT broker to run against, see the instructions in ${REPO}/tests/integration_test.rs.

Run the test command-line app

Run cargo run --example mqttc to print usage.

The test app requires an MQTT broker to run against, see the instructions in ${REPO}/tests/integration_test.rs.

Run cargo run --example mqttc -- --host localhost publish topic payload to publish payload payload to topic topic.

Run RUST_LOG="info" cargo run --example mqttc -- --host localhost subscribe topic to subscribe to topic topic and print any messages that are published to it.



  • Add --tls-client-crt-file and --tls-client-rsa-key-file options to the example mqttc. Thanks to marcelbuesing for the PR!
  • Add more explanation of how to configure TLS to the ClientBuilder docs.


  • Add WebSocket support under Cargo feature "websocket".
  • Switch ClientBuilder to use a URL instead of host and port. This was a breaking change to make it simple for consumers to switch protocol.

Thanks to JarredAllen for the implementation!


  • Update tokio dependency to v1.2.0. Thanks to marcelbuesing for the PR!


  • Implement Debug for Client and ClientOptions
  • Reduce dependencies for faster and less fiddly builds: env_logger and structopt are now dev-dependencies, rustls is now optional but included by default as part of the tls feature.

Thanks to marcelbuesing for the PRs!


  • Client is Send.


  • Correctly connect only once when automatic_connect is disabled.


  • Missing ping responses should cause a disconnect even when keepalive > op timeout.

  • Publish with retain flag.


  • Added timeouts to disconnect, and publish when QoS=0.


  • Enable automatic reconnects by default.

  • This tracks subscriptions and replays them after reconnecting. No publish retries yet.


~271K SLoC