HiveMQ MQTT CLI

repository·master·Indexed 18 days ago

https://github.com/hivemq/mqtt-cli

A 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.

Tokens
40.6K
Snippets
194
Records
236
Agent score
61%

What's inside mqtt-cli

  1. Manage behavior validation policies with `behavior-policy`

    master

    The mqtt hivemq behavior-policy command 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-policy
  2. Manage HiveMQ Data Hub scripts

    master

    The mqtt hivemq script command 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.

  3. Key features of MQTT CLI

    master

    MQTT 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.
  4. Manage HiveMQ Data Policies

    master

    The data-policy command 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.
  5. Uniquely identifying a client for disconnection

    master

    To 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.

  6. Build and serve the documentation locally

    master

    The documentation is built using Jekyll. To start a local development server:

    1. Run bundler exec jekyll serve.
      • Use the --incremental flag to enable incremental builds, which results in faster build times.
    2. 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
  7. Disconnect a specific client

    master

    To disconnect a client, use the disconnect (or dis) 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.com
  8. Install rbenv for documentation builds

    master

    To build the documentation, you need rbenv to manage the Ruby version. Follow the instructions for your operating system:

    MacOS:

    1. Install Homebrew.
    2. Run brew install rbenv ruby-build.
    3. Run rbenv init.

    Linux:

    1. Run sudo apt install rbenv.
    2. Run rbenv init.

    Windows: Follow the instructions for rbenv-win.

    After installation, run rbenv install in the project directory to install the specific Ruby version defined in the .ruby-version file.

    brew install rbenv ruby-build
    rbenv init
    rbenv install
  9. Query MQTT client behavior validation state

    master

    The mqtt hivemq behavior-state command 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-state
  10. Install Bundler and dependencies

    master

    Once Ruby is configured via rbenv, use bundler to install the required Ruby gems for the documentation site. Run these commands in the project directory:

    1. Install bundler to your user directory: gem install --user-install bundler.
    2. Install project dependencies: bundle install.
    gem install --user-install bundler
    bundle install