Skip to content

Installation

Fabrício Bracht edited this page Jul 3, 2026 · 1 revision

Installation

Rust Library

Add to your Cargo.toml:

[dependencies]
mqtt5 = "0.34"

For async runtime, you'll also need Tokio:

[dependencies]
mqtt5 = "0.34"
tokio = { version = "1", features = ["full"] }

Feature Flags

The mqtt5 crate enables transport-websocket and transport-quic by default.

Feature Description Default
transport-websocket WebSocket transport (ws://, wss://) Yes
transport-quic QUIC transport (quic://, quics://) Yes
codec-gzip gzip payload compression codec No
codec-deflate deflate payload compression codec No
codec-all Enable all payload codecs (codec-gzip + codec-deflate) No
opentelemetry Distributed tracing with OpenTelemetry (OTLP export) No
tokio Re-export the Tokio dependency No
turmoil-testing Deterministic network-simulation testing with turmoil No

Disable the defaults to build a TCP/TLS-only client:

mqtt5 = { version = "0.34", default-features = false }

Enable optional features as needed:

mqtt5 = { version = "0.34", features = ["opentelemetry", "codec-all"] }

CLI Tool

From crates.io (Recommended)

cargo install mqttv5-cli

From Source

git clone https://github.com/LabOverWire/mqtt-lib.git
cd mqtt-lib
cargo build --release -p mqttv5-cli

# Binary is at target/release/mqttv5

Verify Installation

mqttv5 --version
mqttv5 --help

Docker

Pull from GitHub Container Registry

# Latest release
docker pull ghcr.io/laboverwire/mqtt-lib:latest

# Specific version
docker pull ghcr.io/laboverwire/mqtt-lib:0.34.0

Run Broker

# Basic broker on port 1883 (anonymous access)
docker run -p 1883:1883 ghcr.io/laboverwire/mqtt-lib broker --allow-anonymous

# With TLS (mount certificates)
docker run -p 1883:1883 -p 8883:8883 \
  -v /path/to/certs:/certs:ro \
  ghcr.io/laboverwire/mqtt-lib broker \
  --allow-anonymous \
  --tls-cert /certs/server.pem \
  --tls-key /certs/server.key

The image sets MQTT5_NON_INTERACTIVE=true, so the broker will not prompt for missing arguments.

Available Ports

The image exposes the following ports:

Port Protocol
1883 MQTT (TCP)
8883 MQTTS (TLS)
8080 WebSocket
8443 WebSocket TLS
14567/udp QUIC

Protocol Crate (Embedded / no_std)

For embedded systems or when you only need packet encoding:

[dependencies]
mqtt5-protocol = { version = "0.14", default-features = false }

The std feature is enabled by default (pulls in thiserror and tracing); disabling default features builds for no_std (requires alloc).

See Embedded Guide for target-specific configuration.


WASM / Browser

npm

npm install mqtt5-wasm

Yarn

yarn add mqtt5-wasm

ES Module

import init, { MqttClient } from "mqtt5-wasm";

await init();
const client = new MqttClient("my-client");

See WASM Guide for complete browser setup.


Platform Support

Platform Crate Notes
Linux x86_64 mqtt5, mqttv5-cli Full support
Linux ARM64 mqtt5, mqttv5-cli Full support
macOS x86_64 mqtt5, mqttv5-cli Full support
macOS ARM64 mqtt5, mqttv5-cli Full support (Apple Silicon)
Windows x86_64 mqtt5, mqttv5-cli Full support
WebAssembly mqtt5-wasm Browser only
ARM Cortex-M mqtt5-protocol no_std
RISC-V mqtt5-protocol no_std
ESP32 mqtt5-protocol no_std

Clone this wiki locally