HiveMQ MQTT CLI
repository·master·Indexed 18 days ago
https://github.com/hivemq/mqtt-cliA feature-rich command line interface for interacting with MQTT brokers. It supports publishing (mqtt pub), subscribing (mqtt sub), an interactive shell mode (mqtt sh), and broker testing (mqtt test). Additionally, it includes the 'mqtt hivemq' command group for specialized HiveMQ Broker operations, such as managing data policies, behavior policies, schemas, scripts, and querying behavior validation states via the HiveMQ Data Hub API.
What's inside mqtt-cli
- MQTT CLI is an open-source command line interface for MQTT clients. It is fully compatible with both MQTT 5.0 and MQTT 3.1.1 specifications. It is built using the HiveMQ MQTT Client API.
Manage behavior validation policies with `behavior-policy`
masterThe
mqtt hivemq behavior-policycommand allows you to manage behavior validation policies on a HiveMQ node via the HiveMQ Data Hub API. This includes creating, retrieving, updating, listing, and deleting policies.Note: These commands interact with HiveMQ Data Hub, which is a new product and may be subject to breaking changes.
mqtt hivemq behavior-policyManage HiveMQ Data Hub scripts
masterThe
mqtt hivemq scriptcommand provides a suite of tools to manage scripts on a HiveMQ node via the HiveMQ Data Hub API. You can create, retrieve, list, and delete scripts.Note: The HiveMQ Data Hub is a new product; commands using it may be subject to breaking changes in the future.
Key features of MQTT CLI
masterMQTT CLI provides several capabilities for working with MQTT brokers:
- Protocol Support: Full support for all MQTT 3.1.1 and MQTT 5.0 features.
- Execution Modes: Supports Interactive, Direct, and Verbose modes for all MQTT commands.
- Shell Environment: Includes a shell with syntax highlighting and command history.
- Multi-client Connectivity: Ability to connect multiple MQTT clients to different brokers simultaneously.
- Broker Testing: Tools for performing quick broker tests.
- Data Export: Ability to export information from HiveMQ API endpoints.
Export resources from a HiveMQ API endpoint
masterUse themqtt hivemq exportcommand to export various resources from a HiveMQ API endpoint. This command serves as the base for specific export subcommands, such as exporting client details.mqtt hivemq exportManage HiveMQ Data Policies
masterThe
data-policycommand allows you to manage data validation policies via the HiveMQ Data Hub API.Available Commands:
create: Upload a new policy.get: Retrieve an existing policy.update: Modify an existing policy.list: List all policies (with optional filtering).delete: Remove a policy.
Uniquely identifying a client for disconnection
masterTo uniquely identify a specific client for disconnection using the
--identifier(-i) option, you must also provide the--host(-h) option.If you specify an identifier without the corresponding hostname, the command will use the default hostname (
localhost), which may result in the command failing to find the target client or causing unexpected behavior.Build and serve the documentation locally
masterThe documentation is built using Jekyll. To start a local development server:
- Run
bundler exec jekyll serve.- Use the
--incrementalflag to enable incremental builds, which results in faster build times.
- Use the
- Open your browser and navigate to
http://localhost:4000/to view the documentation.
bundler exec jekyll serve # Or for faster builds: bundler exec jekyll serve --incremental- Run
Disconnect a specific client
masterTo disconnect a client, use the
disconnect(ordis) command.Important: When using an identifier (
-i) to target a specific client for disconnection, you must also provide the hostname (-h). If the hostname is omitted, the command may not behave as expected.mqtt> con -i myClient myClient@localhost> dis # Disconnecting a specific client by identifier and host: mqtt> dis -i myClient -h broker.hivemq.comInstall rbenv for documentation builds
masterTo build the documentation, you need
rbenvto manage the Ruby version. Follow the instructions for your operating system:MacOS:
- Install Homebrew.
- Run
brew install rbenv ruby-build. - Run
rbenv init.
Linux:
- Run
sudo apt install rbenv. - Run
rbenv init.
Windows: Follow the instructions for rbenv-win.
After installation, run
rbenv installin the project directory to install the specific Ruby version defined in the.ruby-versionfile.brew install rbenv ruby-build rbenv init rbenv installQuery MQTT client behavior validation state
masterThe
mqtt hivemq behavior-statecommand allows you to query the behavior validation state of currently connected MQTT clients via a HiveMQ Data Hub API endpoint. This is useful for inspecting which behavior policies are currently applied to a specific client and what their current states are.Note: This feature uses the HiveMQ Data Hub, which may be subject to breaking changes in future versions.
mqtt hivemq behavior-stateInstall Bundler and dependencies
masterOnce Ruby is configured via
rbenv, usebundlerto install the required Ruby gems for the documentation site. Run these commands in the project directory:- Install bundler to your user directory:
gem install --user-install bundler. - Install project dependencies:
bundle install.
gem install --user-install bundler bundle install- Install bundler to your user directory: