mqttv5-cli-0.11.3 is not a library.
mqttv5 - MQTT v5.0 Command Line Interface
A unified MQTT v5.0 CLI tool with pub, sub, and broker commands.
Features
- Single binary: pub, sub, and broker subcommands
- Interactive prompts for missing arguments
- Input validation with error messages and suggestions
- MQTT v5.0 protocol support
- Session management: Clean start, session expiry, and persistence
- Will message support: Last will and testament with delay and QoS options
- Automatic reconnection: Opt-in reconnection with exponential backoff
- Multi-transport: TCP, TLS, WebSocket, and QUIC support
- Cross-platform: Linux, macOS, and Windows
Installation
Usage
Publishing Messages
# Basic publish
# With QoS and retain
# Interactive mode (prompts for missing args)
Subscribing to Topics
# Basic subscribe
# Verbose mode shows topic names
# Subscribe for specific message count
# Session persistence and QoS
# Auto-reconnect on disconnect (opt-in)
Running a Broker
# Start broker on default port
# Custom port and bind address
# Interactive configuration
CLI Design
- Error messages with suggestions
- Prompts for missing required arguments
- Single binary for all MQTT operations
- Long flags with short aliases
- MQTT v5.0 support including properties and reason codes
Connection Behavior
By default, the CLI exits immediately when the broker disconnects. This prevents duplicate topic takeover issues when clients reconnect with the same client ID.
Use --auto-reconnect to enable automatic reconnection with exponential backoff. When enabled:
- The library handles reconnection automatically
- Subscriptions are restored based on session state
- The client continues running until Ctrl+C or target message count reached
Examples
Publishing sensor data
Monitoring all home sensors
Testing with retained messages
Advanced MQTT v5.0 Features
# Will messages for device monitoring
# Authentication and session management
# Custom keep-alive and transport options
# WebSocket transport
# QUIC transport (insecure mode for testing)
# QUIC transport with certificate verification
# Message expiry and topic alias
# Subscription options (retain handling: 0=send, 1=send if new, 2=don't send)
Environment Variables
MQTT_HOST: Default broker host (default: localhost)MQTT_PORT: Default broker port (default: 1883)
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.