Standalone Installation of HiveMQ on Windows Server 2022

Prerequisites

Install HiveMQ

  • Download and Extract HiveMQ:

  • Doing sanity checks

    • Setting Heap Size to 50% of system memory (4GB in this installation as RAM is 8 GB)

      • Go to C:\hivemq\bin

      • Open the run.bat file with Notepad or any other editor

      • Search for the VARIABLES section

      • The following code example sets the heap size to the recommended 50% of the available RAM:
        set "JAVA_OPTS=%JAVA_OPTS% -XX:+UnlockExperimentalVMOptions -XX:InitialRAMPercentage=40 -XX:MaxRAMPercentage=50 -XX:MinRAMPercentage=30"

      • Save the file

  • Run HiveMQ broker

    • Go to C:\hivemq\bin

    • Right-click on the file “run.bat” and run it as an administrator

    • This should start the HiveMQ process as shown below

End to End connection testing with MQTT CLI

  • Please make sure HiveMQ Broker is running

  • Please make sure that port 1883 is enabled (e.g. inbound rules under security groups)

  • Setup MQTT CLI

  • Download the correct zip for Windows (mqtt-cli-4.27.0-win.zip in our case)

    • Extract the zip file

    • Open the command prompt and CD into the MQTT CLI folder, this folder contains mqtt-cli.exe which will be used for the next steps.

  • Subscribe to a Topic: Subscribe to a topic using MQTT CLI with the command:

    mqtt-cli.exe sub -h localhost -p 1883 -i MQTTCLIClientSUB -t "connection/test"

    This command subscribes to the topic connection/test on the broker running on localhost.

  • Publish to the Same Topic: Open another command prompt window, CD to the MQTT CLI folder, and publish a message to the same topic with:

    mqtt-cli.exe pub -h localhost -p 1883 -i MQTTCLIClientPUB -t "connection/test" -m "Test MQTT CLI"

    This publishes the message "Test MQTT CLI" to the connection/test topic.

  • Verify Message Receipt: Check the first command prompt window where you subscribed to the topic. You should see the message "Test MQTT CLI" appear, indicating that the message was successfully published and received.

Next steps