Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration

Broker Configuration

The broker can be configured via command-line arguments:

mqtt-broker [OPTIONS]

Available Options

OptionDefaultDescription
-h, --host <HOST>0.0.0.0Host address to bind to
-p, --port <PORT>1883Port to listen on
--max-clients <N>10000Maximum concurrent connections
--helpPrint help information

Examples

# Listen on localhost only
mqtt-broker --host 127.0.0.1

# Use a different port
mqtt-broker --port 8883

# Limit connections
mqtt-broker --max-clients 1000

# Combine options
mqtt-broker --host 0.0.0.0 --port 1883 --max-clients 5000

Environment Variables

Enable debug logging with the RUST_LOG environment variable:

# Basic info logging
RUST_LOG=info mqtt-broker

# Debug logging
RUST_LOG=debug mqtt-broker

# Trace logging (very verbose)
RUST_LOG=trace mqtt-broker

# Module-specific logging
RUST_LOG=mqtt_broker::server=debug mqtt-broker

Client Configuration

Producer Options

mqtt-producer [OPTIONS] <TOPIC> <MESSAGE>
OptionDefaultDescription
-h, --host <HOST>127.0.0.1Broker host address
-p, --port <PORT>1883Broker port
-q, --qos <QOS>0QoS level (0, 1, 2)
-r, --retainfalseRetain the message
-c, --client <ID>autoClient ID

Consumer Options

mqtt-consumer [OPTIONS] <TOPIC>...
OptionDefaultDescription
-h, --host <HOST>127.0.0.1Broker host address
-p, --port <PORT>1883Broker port
-q, --qos <QOS>0Maximum QoS level
-c, --client <ID>autoClient ID
-n, --count <N>unlimitedExit after N messages

Default Values

The broker uses sensible defaults for production:

SettingDefaultNotes
Max packet size256 KBPer MQTT 3.1.1 spec
Connect timeout10 secondsTime to receive CONNECT
Keep-alive multiplier1.5xPer MQTT spec
Max inflight messages65535Per QoS 1/2 flows
Offline queue size1000Messages per session
Session expiry24 hoursFor persistent sessions

Planned Configuration

Future versions will support:

  • Configuration file (TOML/YAML)
  • TLS/SSL settings
  • Authentication backends
  • Access control lists (ACL)
  • Clustering configuration