Test Your HiveMQ Software Broker

After you deploy HiveMQ Software, use the MQTT CLI to connect clients and test publish and subscribe operations. The MQTT CLI is an open-source Java-based client tool included in the tools directory of HiveMQ version 4.4.0 and higher.

The following steps assume HiveMQ and the MQTT clients run on the same machine. If the broker and clients run on separate systems, replace localhost with your broker address in the commands.

Before You Begin

Connect MQTT Clients to Your Broker

  1. Open a terminal window, go to the tools/mqtt-cli/bin directory in your HiveMQ installation, and start the MQTT CLI in shell mode:

    mqtt sh

    The MQTT CLI starts and lists available options and commands.

  2. Connect your first MQTT client to the broker:

    con -h localhost -i testClient1

    This command creates a client with the identifier testClient1 and connects it to your broker on localhost.

  3. Open a second terminal window and start a second MQTT CLI session:

    mqtt sh
  4. In the second terminal window, connect a second MQTT client:

    con -h localhost -i testClient2

    This command creates a second client with the identifier testClient2 and connects it to your broker on localhost.

Test Subscribe and Publish

  1. In the second terminal window, subscribe to a test topic:

    sub -t testTopic -s
  2. In the first terminal window, publish a test message:

    pub -t testTopic -m Hello

    The message Hello appears immediately in the second terminal window.

  3. Confirm delivery by publishing a second message:

    pub -t testTopic -m Goodbye

    The message Goodbye appears immediately in the second terminal window.