### Get Script Example Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/script.md Example of fetching a script by its ID and displaying its details, including ID, version, creation date, description, function type, and source code. ```bash $ mqtt hivemq script get --id hello_world { "id": "hello_world", "version": 1, "createdAt": "2023-11-03T13:07:15.650Z", "description": "This function greets a person.", "functionType": "TRANSFORMATION", "source": "ZnVuY3Rpb24gdHJhbnNmb3JtKHBlcnNvbikgeyByZXR1cm4gJ2hlbGxvICcgKyBwZXJzb24gfQ==" } ``` -------------------------------- ### Example Publish with Client Context Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/publish.md This example demonstrates publishing a message to the 'test' topic with the message 'msg' using an established client context named 'myClient'. First, connect with the client, then publish. ```shell mqtt> con -i myClient myClient@localhost> pub -t test -m msg ``` -------------------------------- ### Start MQTT CLI Shell with Docker Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/installation.md Start the interactive Shell-Mode of the MQTT CLI using Docker. ```bash docker run -it hivemq/mqtt-cli shell ``` -------------------------------- ### Create Script with File and Options Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/script.md Example of creating a transformation script with a specified ID, description, and source file. ```bash mqtt hivemq script create --id hello_world --description "Yet another hello world script." --file hello.js --type transformation ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/README.md Installs all project dependencies defined in the Gemfile. Execute this in the project directory after installing bundler. ```bash bundle install ``` -------------------------------- ### Install MQTT CLI with Homebrew Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/installation.md Install MQTT CLI on Mac OS X and Linux systems using Homebrew. ```bash brew install hivemq/mqtt-cli/mqtt-cli ``` -------------------------------- ### Install Ruby Version Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/README.md Installs the Ruby version specified in the project's .ruby-version file. Execute this in the project directory. ```bash rbenv install ``` -------------------------------- ### Install MQTT CLI RPM Package Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/installation.md Install the MQTT CLI RPM package using yum. ```bash sudo yum install -y https://github.com/hivemq/mqtt-cli/releases/download/v4.52.0/mqtt-cli-4.52.0.rpm ``` -------------------------------- ### Subscribe to a Topic Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/subscribe.md This example shows how to subscribe to the 'test' topic using the 'sub' command after connecting a client. Output is directed to the log file by default. ```shell mqtt> con -i myClient myClient@localhost> sub -t test ``` -------------------------------- ### Interactive Shell Example Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell.md Demonstrates a typical workflow within the MQTT CLI shell, including connecting a client, publishing a message, and disconnecting. ```shell $ mqtt shell # starts the shell mqtt> con -i myClient # connect client with identifier 'myClient' myClient@host> pub -t test -m msg # publish the message 'msg' with the new context client myClient@host> dis # disconnect and remove context mqtt> ... ``` -------------------------------- ### Install Bundler Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/README.md Installs the bundler gem for managing Ruby project dependencies. Execute this in the project directory. ```bash gem install --user-install bundler ``` -------------------------------- ### Simple Example of Exporting Client Details Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/export.md Demonstrates the basic execution of the 'export clients' command. The output indicates the progress and successful completion of the export, including the filename where details are saved. ```bash $ mqtt hivemq export clients Exporting client details: ... Successfully exported x client details to hivemq_client_details_2020-07-30-11:06:24.csv ``` -------------------------------- ### Install MQTT CLI Debian Package Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/installation.md Download and install the MQTT CLI Debian package using wget and apt. ```bash wget https://github.com/hivemq/mqtt-cli/releases/download/v4.52.0/mqtt-cli-4.52.0.deb sudo apt install ./mqtt-cli-4.52.0.deb ``` -------------------------------- ### Start Run Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/swarm/run.md The base command to start a HiveMQ Swarm run. ```bash mqtt swarm run start ``` -------------------------------- ### Show Supported Commands Source: https://github.com/hivemq/mqtt-cli/blob/master/README.txt Displays all available commands supported by the MQTT CLI. Use this to get an overview of the tool's capabilities. ```bash $ mqtt ``` -------------------------------- ### Enter MQTT CLI Shell Mode Source: https://github.com/hivemq/mqtt-cli/blob/master/README.md Quick start for entering the mqtt-cli shell mode, which provides access to more MQTT functionalities. ```bash mqtt sh ``` -------------------------------- ### Start Interactive MQTT Shell Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/quick-start.md Starts the MQTT CLI in interactive shell mode, allowing for more complex MQTT operations. Use this for an interactive session. ```bash $ mqtt shell ... mqtt> ``` -------------------------------- ### Install rbenv on macOS Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/README.md Installs rbenv on macOS using Homebrew. Ensure Homebrew is installed first. ```bash brew install rbenv ruby-build rbenv init ``` -------------------------------- ### Create Behavior Policy from File Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/behavior-policy.md Example of creating a behavior policy by specifying a JSON file containing the policy definition. ```bash mqtt hivemq behavior-policy create --file my-policy.json ``` -------------------------------- ### Start Run in Detached Mode Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/swarm/run.md Uploads and executes a scenario from a file in detached mode. The command returns immediately after the scenario has started. ```bash $ mqtt swarm run start -f /path/to/scenario -d Successfully uploaded scenario. Scenario-id: 2 Run id: 1 Run status: STARTING ``` -------------------------------- ### List Scripts Example with Filter Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/script.md Example of listing scripts filtered by a specific ID. The output includes details for each matching script, such as ID, version, creation date, description, function type, and source code. ```bash $ mqtt hivemq script list --id hello_world { "items": [ { "id": "hello_world", "version": 1, "createdAt": "2023-11-03T13:59:47.262Z", "description": "This function greets a person.", "functionType": "TRANSFORMATION", "source": "ZnVuY3Rpb24gdHJhbnNmb3JtKHBlcnNvbikgeyByZXR1cm4gJ2hlbGxvICcgKyBwZXJzb24gfQ==" }, { "id": "hello_world", "version": 2, "createdAt": "2023-11-03T13:59:48.348Z", "description": "This function greets a person.", "functionType": "TRANSFORMATION", "source": "ZnVuY3Rpb24gdHJhbnNmb3JtKHBlcnNvbikgeyByZXR1cm4gJ2hlbGxvICcgKyBwZXJzb24gfQ==" } ] } ``` -------------------------------- ### Test MQTT Broker Features Source: https://github.com/hivemq/mqtt-cli/blob/master/README.md Quick start for running tests against an MQTT broker to determine its features and limitations. Requires specifying the broker host. ```bash mqtt test -h your-mqtt-broker.com ``` -------------------------------- ### Get Specific Behavior Policy by ID Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/behavior-policy.md Example of retrieving a specific behavior policy using its ID. The output shows the JSON structure of a behavior policy. ```bash $ mqtt hivemq behavior-policy get --id matchingThree ``` ```json { "id": "matchingThree", "createdAt": "2023-09-21T11:24:25.464Z", "lastUpdatedAt": "2023-09-21T11:24:25.464Z", "matching": { "clientIdRegex": "three.*" }, "deserialization": { "publish": { "schema": { "schemaId": "one", "version": "latest" } }, "will": { "schema": { "schemaId": "one", "version": "latest" } } }, "behavior": { "id": "Mqtt.events", "arguments": {} }, "onTransitions": [] } ``` -------------------------------- ### Install rbenv on Linux Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/README.md Installs rbenv on Linux systems using apt package manager. Requires sudo privileges. ```bash sudo apt install rbenv rbenv init ``` -------------------------------- ### Subscribe to MQTT Topic Source: https://github.com/hivemq/mqtt-cli/blob/master/README.md Quick start for subscribing to an MQTT topic and receiving messages directly on the console. Requires specifying the topic and broker host. ```bash mqtt sub -t your-topic -h your-mqtt-broker.com ``` -------------------------------- ### Basic Subscribe Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/subscribe.md The basic subscribe command to start listening to topics. It blocks the console by default. ```bash mqtt subscribe ``` -------------------------------- ### Unsubscribe from a Specific Topic Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/unsubscribe.md Demonstrates connecting a client, subscribing to multiple topics, and then unsubscribing from one specific topic. This example shows a common workflow for managing subscriptions. ```shell mqtt> con -i myClient myClient@localhost> sub -t topic1 -t topic2 myClient@localhost> unsub -t topic1 mqtt> ``` -------------------------------- ### Get Behavior Policy Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/behavior-policy.md The base command for retrieving an existing behavior policy. ```bash mqtt hivemq behavior-policy get ``` -------------------------------- ### Default Configuration Properties Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/configuration.md This is an example of the default properties file generated by MQTT CLI on its first successful execution. It lists various configuration settings as key-value pairs. ```properties mqtt.host=localhost mqtt.port=1883 mqtt.version=5 client.id.prefix=mqtt ws.path=/mqtt client.id.length=8 logfile.level=debug logfile.path=/Users/tseeberg/.mqtt-cli/logs/ ``` -------------------------------- ### Publish MQTT Message Source: https://github.com/hivemq/mqtt-cli/blob/master/README.md Quick start for publishing a message to an MQTT topic. Requires specifying the topic, message, and broker host. ```bash mqtt pub -t your-topic -m "your message" -h your-mqtt-broker.com ``` -------------------------------- ### Get Data Policy Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/data-policy.md The base command for retrieving an existing data policy. ```bash mqtt hivemq data-policy get ``` -------------------------------- ### Update Behavior Policy by ID from File Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/behavior-policy.md Example of updating a behavior policy by specifying its ID and providing the updated definition from a JSON file. ```bash mqtt hivemq behavior-policy update --id my-policy-id --file behavior-one.json ``` -------------------------------- ### Get Script Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/script.md Use this command to retrieve a single existing script from a HiveMQ node. ```bash mqtt hivemq script get ``` -------------------------------- ### Get Behavior State for a Specific Client ID Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/behavior-state.md Fetches the behavior validation states for a client identified by 'my-client-id'. The output details the state of each applicable behavior policy for the client. ```bash $ mqtt hivemq behavior-state get --id my-client-id { "items": [ { "arguments": {}, "behaviorId": "Mqtt.events", "firstSetAt": "2023-09-21T11:54:35.111Z", "policyId": "matchingOne", "stateName": "Connected", "stateType": "INTERMEDIATE", "variables": {} } ] } ``` -------------------------------- ### Get Behavior State for a Client Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/behavior-state.md Retrieves the behavior validation states for a specific MQTT client ID. This command is useful for debugging and understanding client behavior compliance. ```bash mqtt hivemq behavior-state get ``` -------------------------------- ### Build Windows Zip from Source Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/installation.md Build the Windows zip distribution for MQTT CLI from source. ```bash ./gradlew buildWindowsZip ``` -------------------------------- ### Start Run in Blocking Mode Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/swarm/run.md Uploads and executes a scenario from a file in blocking mode. The command returns after the scenario finishes, and stopping the process also stops the scenario. The scenario is deleted from the HiveMQ Swarm Commander afterward. ```bash $ mqtt swarm run start -f /path/to/scenario Successfully uploaded scenario. Scenario-id: 2 Run id: 1 Run status: STARTING Run status: RUNNING Scenario Stage: Stage with id 's1' (1/3). Run status: RUNNING Scenario Stage: Stage with id 's2' (2/3). Run status: RUNNING Scenario Stage: Stage with id 's3' (3/3). Run status: FINISHED Scenario Stage: Stage with id 's3' (3/3). ``` -------------------------------- ### Exit Current Client Context Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/exit.md Use the 'exit' command to disconnect from the currently active client context. The shell will remain open, allowing you to manage other contexts or start new connections. ```shell mqtt> exit ``` -------------------------------- ### Show Help for All Commands Source: https://github.com/hivemq/mqtt-cli/blob/master/README.txt Provides detailed help information for all MQTT CLI commands. This is useful for understanding command options and usage. ```bash $ mqtt --help ``` -------------------------------- ### MQTT CLI Usage Help Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/quick-start.md Displays the main usage information for the MQTT CLI, listing available commands and options. Run this to see all top-level commands. ```bash $ mqtt Usage: mqtt [-hV] { pub | sub | shell | test | hivemq | swarm } MQTT Command Line Interpreter. Options: -h, --help Show this help message and exit. -V, --version Print version information and exit. Commands: pub, publish Publish a message to a list of topics. sub, subscribe Subscribe an MQTT client to a list of topics. shell, sh Starts MqttCLI in shell mode, to enable interactive mode with further sub commands. test Tests the specified broker on different MQTT feature support and prints the results. hivemq HiveMQ Command Line Interpreter. swarm HiveMQ Swarm Command Line Interpreter. ``` -------------------------------- ### Build Brew Formula from Source Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/installation.md Build the Homebrew formula for MQTT CLI from source. ```bash ./gradlew buildBrewFormula ``` -------------------------------- ### Show Publish Command Help Source: https://github.com/hivemq/mqtt-cli/blob/master/README.txt Displays detailed help for the publish command, including all available options and their usage. ```bash $ mqtt pub --help ``` -------------------------------- ### Build RPM Package from Source Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/installation.md Build the RPM package for MQTT CLI from source. ```bash ./gradlew buildRpmPackage ``` -------------------------------- ### Build Docker Image from Source Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/installation.md Build a local Docker image for MQTT CLI from source. ```bash ./gradlew jibDockerBuild ``` -------------------------------- ### Run Basic Broker Test Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/test.md This command initiates a basic test against the specified broker, checking MQTT 3 features and then MQTT 5 connect restrictions. ```bash mqtt test ``` -------------------------------- ### Serve Documentation Locally Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/README.md Builds and serves the Jekyll documentation website locally. Use --incremental for faster rebuilds during development. ```bash bundler exec jekyll serve --incremental ``` -------------------------------- ### Build MQTT CLI from Source Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/installation.md Perform a clean build of MQTT CLI from source using Gradle. ```bash ./gradlew clean build ``` -------------------------------- ### Access Local Documentation Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/README.md Opens the locally served documentation website in your browser. ```bash http://localhost:4000/ ``` -------------------------------- ### Build Debian Package from Source Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/installation.md Build the Debian package for MQTT CLI from source. ```bash ./gradlew buildDebianPackage ``` -------------------------------- ### Execute MQTT CLI Source: https://github.com/hivemq/mqtt-cli/blob/master/CONTRIBUTING.md Run the MQTT CLI using the generated JAR file. Replace with the actual version number. ```bash java -jar build/libs/mqtt-cli-.jar ``` -------------------------------- ### Basic Connect Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/connect.md Use the 'connect' or 'con' command to create and connect a new MQTT client with default settings. ```shell mqtt> connect ``` ```shell mqtt> con ``` -------------------------------- ### Run MQTT CLI with Docker Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/installation.md Execute a simple command using the MQTT CLI Docker image. ```bash docker run hivemq/mqtt-cli ``` -------------------------------- ### Get HiveMQ Schema Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/schema.md Command to retrieve a specific schema by its ID. The response includes schema details like ID, type, and definition. ```bash mqtt hivemq schema get --id my-schema-id ``` ```json { "arguments": {}, "createdAt": "2023-05-25T21:10:42.779Z", "id": "my-schema-id", "schemaDefinition": "eyAidHlwZSI6ICJvYmplY3QiIH0K", "type": "JSON" } ``` -------------------------------- ### Show Subscribe Command Help Source: https://github.com/hivemq/mqtt-cli/blob/master/README.txt Displays detailed help for the subscribe command, including all available options and their usage. ```bash $ mqtt sub --help ``` -------------------------------- ### Get HiveMQ Swarm Status Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/swarm/status.md Execute the basic status command to fetch the HiveMQ Swarm status. This command requires no arguments for a default query. ```bash mqtt swarm status ``` -------------------------------- ### List Client Subscriptions Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/list.md Connects a client, subscribes it to topics, and then uses the '-s' option to list the subscribed topics for that client. ```shell client1@localhost> sub -t topic -t topic2 -t topic3 client1@localhost> ls -s client1@localhost -subscribed topics: [topic2, topic3, topic] ``` -------------------------------- ### Test MQTT Broker Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/quick-start.md Runs a quick test suite against the MQTT broker on the default host and port. Use this to verify broker functionality. ```bash $ mqtt test ... ``` -------------------------------- ### Format Code with License Headers Source: https://github.com/hivemq/mqtt-cli/blob/master/CONTRIBUTING.md Format all changed files and add license headers before committing. ```bash ./gradlew licenseFormat ``` -------------------------------- ### Build MQTT CLI Jar Source: https://github.com/hivemq/mqtt-cli/blob/master/CONTRIBUTING.md Build the shadow JAR for the MQTT CLI, which can be used to execute the CLI. ```bash ./gradlew shadowJar ``` -------------------------------- ### Get Specific Data Policy Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/data-policy.md Retrieves a specific data policy by its ID and returns its JSON definition. The output includes creation timestamp, ID, matching topic filter, and validation rules. ```bash $ mqtt hivemq data-policy get --id my-policy-id ``` ```json { "createdAt": "2023-05-25T14:58:09.093Z", "id": "my-policy-id", "matching": { "topicFilter": "topic/1" }, "onFailure": { "pipeline": [] }, "onSuccess": { "pipeline": [] }, "validation": { "validators": [ { "arguments": { "strategy": "ALL_OF", "schemas": [ { "schemaId": "my-schema" } ] }, "type": "schema" } ] } } ``` -------------------------------- ### Connect and Publish Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/connect.md Connect a client with a specific identifier and immediately publish a message. ```shell mqtt> con -i myClient myClient@localhost> pub -t test -m "Hello World" ``` -------------------------------- ### List Clients with Detailed Information Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/list.md Connects a client and then uses the '-l' option to display detailed information about all connected clients, including connection status, time, and protocol version. ```shell mqtt> con -i client1 client1@localhost> exit mqtt> con -i client2 client2@localhost> ls client1@localhost client2@localhost ``` ```shell mqtt> con -i client client@localhost> ls -l total 1 CONNECTED 11:00:29 client1 localhost 1883 MQTT_5_0 NO_SSL ``` -------------------------------- ### Create Data Policy from File Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/data-policy.md Creates a new data policy by specifying the policy definition in a JSON file. ```bash mqtt hivemq data-policy create --file my-policy.json ``` -------------------------------- ### Connect to Host and Port Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/connect.md Connect a client to a specified host and port using the '-h' and '-p' options. ```shell mqtt> con -h myHost -p 1884 ``` -------------------------------- ### Connect with Username and Password Authentication Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/connect.md Connect a client using username and password authentication. The password can be prompted if '-P' is used. ```shell mqtt> con -u username -pw password ``` ```shell mqtt> con -u username -P Enter value for --password (The password for the client UTF-8 String.): ``` -------------------------------- ### Subscribe and Output to File Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/subscribe.md Subscribe to a topic and redirect all received publish messages to a log file. The file is created if it doesn't exist, and new messages are appended. ```bash mqtt sub -t topic -of publishes.log ``` -------------------------------- ### List Connected Clients Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/list.md Lists all currently connected clients in the MQTT CLI session. Use the alias 'ls' for brevity. ```shell mqtt> list ``` ```shell mqtt> ls ``` -------------------------------- ### Create Behavior Policy Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/behavior-policy.md The base command for creating a new behavior policy. ```bash mqtt hivemq behavior-policy create ``` -------------------------------- ### Subscribe to a Topic on a Specific Broker Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/subscribe.md Subscribe to a topic and connect to a broker at a specific address and port. ```bash mqtt sub -t test -h localhost -p 1884 ``` -------------------------------- ### Create Data Policy Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/data-policy.md The base command for creating a new data policy. ```bash mqtt hivemq data-policy create ``` -------------------------------- ### Exit Client Context After Connection Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/exit.md Demonstrates connecting a client with a specific identifier and then exiting that client's context. The client remains connected in the background, and the shell is ready for further commands. ```shell mqtt> con -i client client@localhost> exit mqtt> ``` -------------------------------- ### Publish with Per-Topic QoS Levels Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/publish.md Publishes messages to different topics, each with a specific QoS level assigned individually. ```bash mqtt pub -t topic1 -q 0 -t topic2 -q 1 -t topic3 -q 2 ``` -------------------------------- ### Test Broker Features Source: https://github.com/hivemq/mqtt-cli/blob/master/README.txt Runs a series of tests against a specified broker to determine its features and limitations. By default, it uses MQTT 3 clients and then checks MQTT 5 connect restrictions. ```bash $ mqtt test -h broker.hivemq.com ``` -------------------------------- ### Subscribe to a Single Topic Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/subscribe.md Subscribe to a single topic with default settings. The command will block the console. ```bash mqtt sub -t topic ``` -------------------------------- ### Connect with Specific Settings and Disconnect Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/connect.md Connect a client with a specific identifier and custom host/version, then disconnect it using the 'dis' command. ```shell mqtt> con -i myClient -h broker.hivemq.com -V 3 myClient@localhost> exit # client is still connected mqtt> dis -i myClient -h broker.hivemq.com ``` -------------------------------- ### Test Broker with Hostname Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/test.md Tests the broker at `broker.hivemq.com`, reporting results for both MQTT 3 and MQTT 5, including detailed feature checks like maximum topic length and QoS performance. ```bash $ mqtt test -h broker.hivemq.com MQTT 3: OK - Maximum topic length: 65535 bytes - QoS 0: Received 10/10 publishes in 47,59ms - QoS 1: Received 10/10 publishes in 68,87ms - QoS 2: Received 10/10 publishes in 43,18ms - Retain: OK - Wildcard subscriptions: OK - Shared subscriptions: OK - Payload size: >= 100000 bytes - Maximum client id length: 65535 bytes - Unsupported Ascii Chars: ALL SUPPORTED MQTT 5: OK - Connect restrictions: > Retain: OK > Wildcard subscriptions: OK > Shared subscriptions: OK > Subscription identifiers: OK > Maximum QoS: 2 > Receive maximum: 10 > Maximum packet size: 268435460 bytes > Topic alias maximum: 5 > Session expiry interval: Client-based > Server keep alive: Client-based ``` -------------------------------- ### Clone MQTT CLI Repository Source: https://github.com/hivemq/mqtt-cli/blob/master/CONTRIBUTING.md Clone your forked repository using IntelliJ or the git command line. ```git git clone https://github.com/yourgithubname/mqtt-cli.git ``` -------------------------------- ### Perform MQTT 5 Only Tests Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/test.md This command specifically tests the broker using only MQTT 5, performing all available tests for this version. ```bash $ mqtt test -h broker.hivemq.com -a -V 5 MQTT 5: OK - Connect restrictions: > Retain: OK > Wildcard subscriptions: OK > Shared subscriptions: OK > Subscription identifiers: OK > Maximum QoS: 2 > Receive maximum: 10 > Maximum packet size: 268435460 bytes > Topic alias maximum: 5 > Session expiry interval: Client-based > Server keep alive: Client-based - Maximum topic length: 65535 bytes - QoS 0: Received 10/10 publishes in 52,70ms - QoS 1: Received 10/10 publishes in 79,95ms - QoS 2: Received 10/10 publishes in 125,65ms - Retain: OK - Wildcard subscriptions: OK - Shared subscriptions: OK - Payload size: >= 100000 bytes - Maximum client id length: 65535 bytes - Unsupported Ascii Chars: ALL SUPPORTED ``` -------------------------------- ### Subscribe with Specific QoS per Topic Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/subscribe.md Subscribe to multiple topics, assigning a specific QoS level to each topic individually. ```bash mqtt sub -t topic1 -q 0 -t topic2 -q 1 -t topic3 -q 2 ``` -------------------------------- ### Connect and Disconnect Client with Host Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/disconnect.md Shows connecting a client to a specific host and identifier, then disconnecting it using the 'disconnect' command. ```shell mqtt> con -i myClient -h broker.hivemq.com myClient@localhost> exit # client is still connected mqtt> dis -i myClient -h broker.hivemq.com ``` -------------------------------- ### Publish Command with Context Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/publish.md This command publishes a message using the currently active client context. It does not create a new connection or client. ```shell client@host> publish ``` -------------------------------- ### Connect an MQTT Client in Shell Mode Source: https://github.com/hivemq/mqtt-cli/blob/master/README.txt Connects a new MQTT client within the shell mode, assigning it a specific client identifier. This establishes a context for subsequent commands. ```bash $ mqtt> con -i myClient ``` -------------------------------- ### Connect with SSL and Mutual Authentication Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/connect.md Connect a client using SSL with both client-side and server-side authentication, specifying certificate paths and TLS version. The private key password will be prompted. ```shell mqtt> con --cafile pathToServerCertificate.pem --tls-version TLSv.1.3 --cert pathToClientCertificate.pem --key pathToClientKey.pem Enter private key password: ``` -------------------------------- ### Publish with Exactly Once QoS Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/publish.md Publishes a message to multiple topics with the highest QoS level (2), ensuring exactly-once delivery. ```bash mqtt pub -t topic1 -t topic2 -q 2 ``` -------------------------------- ### Basic Publish Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/publish.md The fundamental command to publish a message to a topic using default settings. ```bash mqtt publish ``` -------------------------------- ### Connect with Specific MQTT Version and Host Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/connect.md Connect an MQTT 3.1.1 client to a specified host using the '-V' and '-h' options. ```shell mqtt> con -V 3 -h myHost ``` -------------------------------- ### Subscribe and Output to Specific File Path Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/subscribe.md Subscribe to a topic and redirect received messages to a file in a specified directory. The file is created if it doesn't exist, and new messages are appended. ```bash mqtt sub -t topic -of /usr/local/var/publishes.log ``` -------------------------------- ### Create Script Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/script.md Use this command to create a new script and upload it to a HiveMQ node. The script definition can be provided directly or from a file. ```bash mqtt hivemq script create ``` -------------------------------- ### Switch to a different client context Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/switch.md Use the 'switch' command followed by the client identifier or the full client identifier@host to change the active context. This is useful when you have multiple clients connected and need to interact with a specific one. ```shell mqtt> switch ``` ```shell mqtt> con -i client1 client1@localhost> exit mqtt> con -i client2 -h broker.hivemq.com client2@broker.hivemq.com> switch client1 client1@localhost> switch client2@broker.hivemq.com client2@broker.hivemq.com> ``` -------------------------------- ### Connect with Client Identifier and Custom Port Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/connect.md Connect an MQTT client to localhost on a specific port, identified by a unique client ID using '-i' and '-p'. ```shell mqtt> con -i mqtt-client -p 1884 ``` -------------------------------- ### List Data Policies Filtered by Topic Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/data-policy.md Lists data policies that match a specific MQTT topic. The output includes details of the policies found. ```bash mqtt hivemq data-policy list --topic topic/1 ``` ```json { "items": [ { "createdAt": "2023-05-25T14:59:03.303Z", "id": "policy-1", "matching": { "topicFilter": "#" }, "onFailure": { "pipeline": [] }, "onSuccess": { "pipeline": [] }, "validation": { "validators": [ { "arguments": { "strategy": "ALL_OF", "schemas": [ { "schemaId": "schema-1" } ] }, "type": "schema" } ] } }, { "createdAt": "2023-05-25T15:18:09.093Z", "id": "policy-2", "matching": { "topicFilter": "topic/1" }, "onFailure": { "pipeline": [] }, "onSuccess": { "pipeline": [] }, "validation": { "validators": [ { "arguments": { "strategy": "ALL_OF", "schemas": [ { "schemaId": "schema-2" } ] }, "type": "schema" } ] } } ] } ``` -------------------------------- ### Subscribe with Exactly Once QoS Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/subscribe.md Subscribe to topics with the 'Exactly Once' Quality of Service (QoS) level. If a single QoS is specified for multiple topics, it applies to all. ```bash mqtt sub -t topic1 -t topic2 -q 2 ``` -------------------------------- ### Show HiveMQ Specific Commands Source: https://github.com/hivemq/mqtt-cli/blob/master/README.txt Displays all available HiveMQ-specific commands. These commands offer extended functionality for interacting with HiveMQ brokers. ```bash $ mqtt hivemq ``` -------------------------------- ### Connect, Disconnect, and Exit Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/connect.md Connect a client with a specific identifier, then disconnect it using the 'dis' command. ```shell mqtt> con -i myClient myClient@localhost> dis mqtt> ``` -------------------------------- ### Direct Debug Logging for Publish Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/logging.md Enables debug logging for the MQTT publish command, showing connection details and publish messages. Use the -d option for detailed output. ```shell $ mqtt pub -i c1 -t test -m "Hello World" -d -h broker.hivemq.com Client 'c1@broker.hivemq.com' sending CONNECT MqttConnect{keepAlive=60, cleanStart=true, sessionExpiryInterval=0} Client 'c1@broker.hivemq.com' received CONNACK MqttConnAck{reasonCode=SUCCESS, sessionPresent=false, restrictions=MqttConnAckRestrictions{receiveMaximum=10, maximumPacketSize=268435460, topicAliasMaximum=5, maximumQos=EXACTLY_ONCE, retainAvailable=true, wildcardSubscriptionAvailable=true, sharedSubscriptionAvailable=true, subscriptionIdentifiersAvailable=true}} Client 'c1@broker.hivemq.com' sending PUBLISH ('Hello World') MqttPublish{topic=test, payload=11byte, qos=AT_MOST_ONCE, retain=false} Client 'c1@broker.hivemq.com' finish PUBLISH MqttPublishResult{publish=MqttPublish{topic=test, payload=11byte, qos=AT_MOST_ONCE, retain=false}} ``` -------------------------------- ### Basic MQTT Publish Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/quick-start.md Publishes a message to a specified topic on the default broker (localhost:1883). The client disconnects after publishing. ```bash mqtt pub -t topic -m "Hello World" ``` -------------------------------- ### Connect with Will Message Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/connect.md Connect a client and configure a will message with a topic, QoS, and message content. ```shell mqtt> con -wt willtopic -wq 2 -wm "Client disconnected ungracefully" ``` -------------------------------- ### Basic Run Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/swarm/run.md The base command to initiate a HiveMQ Swarm run. ```bash mqtt swarm run ``` -------------------------------- ### Subscribe to a Topic on a Specific Host and Port Source: https://github.com/hivemq/mqtt-cli/blob/master/README.txt Subscribes to a topic on a non-default host and port. This allows connecting to brokers on custom network configurations. ```bash $ mqtt sub -t test -h localhost -p 1884 ``` -------------------------------- ### Subscribe and Output in Base64 Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/subscribe.md Subscribe to a topic and output all received messages encoded in base64. ```bash mqtt sub -t topic -b64 ``` -------------------------------- ### Subscribe with Alias Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/subscribe.md The 'sub' command is an alias for the 'subscribe' command, offering a shorter way to initiate topic subscriptions. ```shell client@host> sub ``` -------------------------------- ### Subscribe to a Topic Source: https://github.com/hivemq/mqtt-cli/blob/master/README.txt Subscribes to a single topic using default settings and blocks the console to display incoming messages. This is a basic subscription command. ```bash $ mqtt sub -t topic ``` -------------------------------- ### Publish Message from File Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/publish.md Publishes the content of a file as the message payload to a specified topic. ```bash mqtt pub -t test -m:file payload.txt ``` -------------------------------- ### HiveMQ Script Command Overview Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/script.md This is the base command for interacting with HiveMQ scripts. ```bash mqtt hivemq script ``` -------------------------------- ### List HiveMQ Schemas Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/schema.md Command to list all existing schemas on a HiveMQ node. Filtering by schema ID and type is supported. ```bash mqtt hivemq schema list ``` -------------------------------- ### Publish a Message to a Topic Source: https://github.com/hivemq/mqtt-cli/blob/master/README.txt Publishes a specified message to a single topic. This is a fundamental command for sending data via MQTT. ```bash $ mqtt pub -t test -m "Hello" ``` -------------------------------- ### List All Behavior Policies Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/behavior-policy.md Lists all behavior policies on a HiveMQ node. This command can be filtered by policy ID. ```bash mqtt hivemq behavior-policy list ``` -------------------------------- ### List All Data Policies Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/data-policy.md Lists all data policies on a HiveMQ node. This command can be filtered by policy ID, schema ID, and MQTT topic. ```bash mqtt hivemq data-policy list ``` -------------------------------- ### Subscribe to Multiple Topics Source: https://github.com/hivemq/mqtt-cli/blob/master/README.txt Subscribes to multiple topics simultaneously using default settings. The console will block to display incoming messages for all specified topics. ```bash $ mqtt sub -t test1 - test2 ``` -------------------------------- ### Basic Subscribe Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/subscribe.md This is the basic syntax for the subscribe command in the MQTT CLI. It is used to subscribe to topics. ```shell client@host> subscribe ``` -------------------------------- ### Basic MQTT Subscribe Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/quick-start.md Subscribes to a specified topic on the default broker (localhost:1883) and stays connected to receive messages. Exits on Ctrl+C. ```bash mqtt sub -t topic ``` -------------------------------- ### Create HiveMQ Schema Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/schema.md Command to create a new schema. Provide the schema ID, type, and either a file path or definition. For Protobuf types, specify the message type. ```bash mqtt hivemq schema create --id my-schema-id --type PROTOBUF --file my-schema.desc --message-type Message ``` -------------------------------- ### Update Data Policy with File Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/data-policy.md Updates an existing data policy using a JSON file for the new policy definition. The policy ID must match the ID within the definition. ```bash mqtt hivemq data-policy update --id my-policy-id --file my-policy.json ``` -------------------------------- ### Loop through site posts Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_includes/news.md Iterates over the site.posts collection to display a list of post titles and dates. ```liquid {% for post in site.posts %} - [{{ post.title }} ({{ post.date | date_to_string }})]({{ post.url | absolute_url }}) {% endfor %} ``` -------------------------------- ### HiveMQ CLI Schema Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/schema.md The base command for interacting with HiveMQ schemas. ```bash mqtt hivemq schema ``` -------------------------------- ### Alias for Publish Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/publish.md This shows the alias for the publish command when using an active client context. ```shell client@host> pub ``` -------------------------------- ### Publish a Message in Shell Mode Context Source: https://github.com/hivemq/mqtt-cli/blob/master/README.txt Publishes a message to a topic using the currently active client context in shell mode. Commands in this mode relate to the active client. ```bash $ myClient> pub -t test -m msg ``` -------------------------------- ### Disconnect All Clients Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/disconnect.md Use the --all option to disconnect all connected clients simultaneously. ```shell mqtt> disconnect --all ``` -------------------------------- ### HiveMQ CLI Behavior Policy Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/behavior-policy.md The base command for interacting with behavior policies. ```bash mqtt hivemq behavior-policy ``` -------------------------------- ### List Schemas with ID Filter Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/schema.md Lists schemas filtered by a specific schema ID. The output displays details of matching schemas, including their ID, version, creation date, type, schema definition, and arguments. ```bash $ mqtt hivemq schema list --id schema-1 { "items": [ { "id": "schema-1", "version": 1, "createdAt": "2023-06-12T00:38:34.911Z", "type": "JSON", "schemaDefinition": "ewogICJkZXNjcmlwdGlvbiI6ICJUaGlzIGlzIGFub3RoZXIgZ2VuZXJpYyBKU09OIHNjaGVtYSwgc2luY2UgaXQgcmVxdWlyZXMganVzdCBhIEpTT04sIG5vdGhpbmcgZnVydGhlciBzcGVjaWZpZWQiLAogICJ0eXBlIjogIm9iamVjdCIKfQo", "arguments": {} }, { "id": "schema-1", "version": 2, "createdAt": "2023-06-12T09:57:55.862Z", "type": "JSON", "schemaDefinition": "ewogICJkZXNjcmlwdGlvbiI6ICJUaGlzIGlzIGEgdGhlIG1vc3QgZ2VuZXJpYyBKU09OIHNjaGVtYSwgc2luY2UgaXQgcmVxdWlyZXMganVzdCBhIEpTT04sIG5vdGhpbmcgZnVydGhlciBzcGVjaWZpZWQiLAogICJ0eXBlIjogIm9iamVjdCIKfQ==", "arguments": {} } ] } ``` -------------------------------- ### Export HiveMQ Client Details Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/hivemq/export.md Command to export client details from a HiveMQ node. This command initiates the process of retrieving and saving client information. ```bash mqtt hivemq export clients ``` -------------------------------- ### Export HiveMQ Resources Source: https://github.com/hivemq/mqtt-cli/blob/master/README.txt Initiates the export of various resources from a HiveMQ API endpoint. This command is the entry point for data export operations. ```bash $ mqtt hivemq export ``` -------------------------------- ### Exit the MQTT CLI Shell Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/exit.md Use the 'exit' command when no client context is active to terminate the entire MQTT CLI shell session. This will return you to your system's command prompt. ```shell mqtt> exit $ ``` -------------------------------- ### Basic Unsubscribe Command Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/shell/unsubscribe.md Unsubscribes the currently active context client from a list of topics. This command is only available in Shell mode. ```shell client@host> unsubscribe ``` -------------------------------- ### HiveMQ Command Line Interface Source: https://github.com/hivemq/mqtt-cli/blob/master/docs/_docs/quick-start.md Accesses the HiveMQ-specific command line interpreter for interacting with a running HiveMQ instance. Use this for HiveMQ management tasks. ```bash $ mqtt hivemq Usage: mqtt hivemq [-hV] [COMMAND] HiveMQ Command Line Interpreter. Options: -h, --help Show this help message and exit. -V, --version Print version information and exit. Commands: export Exports the specified details from HiveMQ ```