#mqtt #iot #broker #nats #kafka #light-weight #config-file

bin+lib rumqttd

rumqttd is a high performance MQTT broker written in Rust which is light weight and embeddable

34 releases (19 breaking)

0.19.0 Dec 12, 2023
0.18.0 Sep 12, 2023
0.17.0 Aug 15, 2023
0.16.0 Jul 24, 2023
0.0.1 May 15, 2020

#167 in Network programming

Download history 527/week @ 2023-12-23 1610/week @ 2023-12-30 2770/week @ 2024-01-06 2188/week @ 2024-01-13 2602/week @ 2024-01-20 2742/week @ 2024-01-27 1639/week @ 2024-02-03 2614/week @ 2024-02-10 1901/week @ 2024-02-17 2133/week @ 2024-02-24 2267/week @ 2024-03-02 1681/week @ 2024-03-09 2358/week @ 2024-03-16 1802/week @ 2024-03-23 2129/week @ 2024-03-30 684/week @ 2024-04-06

7,448 downloads per month
Used in 8 crates (7 directly)

Apache-2.0

470KB
10K SLoC

rumqttd

crates.io page docs.rs page

Rumqttd is a high performance MQTT broker written in Rust. It's light weight and embeddable, meaning you can use it as a library in your code and extend functionality

Getting started

You can directly run the broker by running the binary with a config file with:

cargo run --release -- -c rumqttd.toml

Example config file is provided on the root of the repo.

Building the docker image

In order to run rumqttd within a docker container, build the image by running build_rumqttd_docker.sh from the project's root directory. The shell script will use docker to build rumqttd and package it along in an alpine image. You can then run rumqttd using default config with:

./build_rumqttd_docker.sh
docker run -p 1883:1883 -p 1884:1884 -it rumqttd

Or you can run rumqttd with the custom config file by mounting the file and passing it as argument:

./build_rumqttd_docker.sh
docker run -p 1883:1883 -p 1884:1884 -v /absolute/path/to/rumqttd.toml:/rumqttd.toml -it rumqttd -c /rumqttd.toml

How to use with TLS

To connect an MQTT client to rumqttd over TLS, create relevant certificates for the broker and client using provision as follows:

provision ca // generates ca.cert.pem and ca.key.pem
provision server --ca ca.cert.pem --cakey ca.key.pem --domain localhost // generates localhost.cert.pem and localhost.key.pem
provision client --ca ca.cert.pem --cakey ca.key.pem --device 1 --tenant a // generates 1.cert.pem and 1.key.pem

Update config files for rumqttd and rumqttc with the generated certificates:

[v4.2.tls]
    certpath = "path/to/localhost.cert.pem"
    keypath = "path/to/localhost.key.pem"
    capath = "path/to/ca.cert.pem"

You may also use certgen, tls-gen or openssl to generate self-signed certificates, though we recommend using provision.

NOTE: Mount the folders containing the generated tls certificates and the proper config file(with absolute paths to the certificate) to enable tls connections with rumqttd running inside docker.

Dynamically update log filter

Log levels and filters can by dynamically updated without restarting broker. To update the filter, we can send a POST request to /logs endpoint, which is exposed by our console, with new filter as plaintext in body. For example, to get logs of rumqttd ( running locally and expose console at port 3030 ) with log level "debug", we can do:

curl -H "Content-Type: text/plain" -d "rumqttd=debug" 0.0.0.0:3030/logs

The general syntax for filter is:

target[span{field=value}]=level

So filter for logs of client with id "pub-001" which has occurred any any span will be [{client_id=pub-001}]. Know more about it here

Dependencies

~17–35MB
~521K SLoC