Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Test the connection with a different MQTT client.
    We recommend using the MQTT-CLI command-line tool.

  2. Attempt to connect using your hostname, port, and credentials.

Expand
titleTest end to end using MQTT-CLI

Connect MQTT clients

Subscribe

To connect to your HiveMQ Cloud cluster and subscribe to the topic my/test/topic, type the following command.

You are asked for the password for the user <your_username>, that you entered before.

Code Block
mqtt sub -h YOUR_CLUSTER_URL -p 8883 -s -u YOUR_USERNAME -pw -t 'my/test/topic'

This is your first connected MQTT client, that is subscribed and waiting for incoming messages.

Publish

To create another client and send messages to your cluster, open a second terminal window and enter the following command: (keep your original terminal window open)

Code Block
mqtt pub -h YOUR_CLUSTER_URL -p 8883 -s -u YOUR_USERNAME -pw -t 'my/test/topic' -m 'Hello'

The message Hello appears immediately in the terminal window of the second MQTT client.

To publish another message, just run the mqtt pub ... command again.