mqttv5-cli-0.8.0 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
- Unified interface: Single binary with pub, sub, and broker subcommands
- Smart prompting: Interactive prompts for missing arguments
- Input validation: Helpful error messages with correction suggestions
- Full MQTT v5.0: Complete 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, and WebSocket support
- Cross-platform: Should work on 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
- Clear, actionable error messages with suggestions
- Intelligent prompting for missing required arguments
- Unified tool: One binary for all MQTT operations
- Consistent flags and intuitive interface
- Full 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
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.