Prerequisites
Running Windows Environment e.g. HiveMQ Installation Guide - Windows Server 2022 on AWS
Check Minimum system hardware requirements https://docs.hivemq.com/hivemq/latest/user-guide/system-requirements.html#minimum
Install JRE (OpenJDK JRE 11 or newer is required.)
Download and Install JRE 11 or later Later https://adoptium.net/en-GB/temurin/releases/?arch=x64&os=windows&package=jre&version=11. Please do note the Java version for the next step (11.0.22 in our case).
(Recommended) Set the Environmental
JAVA_HOME
environment variable during installation can be done by enabling the following settingSet (Manually) If you want to set
JAVA_HOME
Environment Variable manually environment variable manually, follow the steps:Right-click on "This PC" and select "Properties".
Click on "Advanced system settings".
In the System Properties window, go to the "Advanced" tab and click on "Environment Variables".
Under "System Variables", click "New" and add a new variable:
Variable name:
JAVA_HOME
Variable value: the path to your Java installation (e.g.,
C:\Program Files\JavaEclipse Adoptium\jdk-11.0.22.7-hotspot\
).C:\Program Files\Eclipse Adoptium\jdk-11.0.22.7-hotspot\bin
exists under the path system variable list.
Click OK to close all dialogues.
Install HiveMQ
Download and Extract HiveMQ:
First, you need to download the HiveMQ ZIP file from the official HiveMQ website. https://www.hivemq.com/download/
Unzip the folder to C:\ e.g.
C:\hivemq-4.2527.10
Rename this folder to
hivemq
so the path looks likeC:\hivemq
Files inside the folder would have a structure e.g.
C:\hivemq\bin
Doing sanity checks
Setting Heap Size to 50% of system memory (2GB minimum, 4GB in this installation as RAM is 8 GB)
Go to
C:\hivemq\bin
Open the
run.bat
file with notepad Notepad or any other editorSearch for the VARIABLES section
Add the heap configuration (4 GB in this case)The following code example sets the heap size to the recommended 50% of the available RAM:
set "JAVA_OPTS=%JAVA_OPTS% -Xmx4g"
-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 MQTT CLI
Go to the release link https://hivemq.github.iocom/hivemq/mqtt-cli/ and go to the latest release.
...
Download the correct zip for Windows (
25mqtt-cli-4.
on27.0-win.zip
in our case)
Extract the zip file
Open the command prompt and
cdCD 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:
Code Block mqtt-cli.exe sub -h localhost -p 1883 -i MQTTCLIClientSUB -t "connection/test" -d
This command subscribes to the topic
connection/test
on the broker running onlocalhost
.Publish to the Same Topic: Open another command prompt window, cd CD to the mqttcli MQTT CLI folder, and publish a message to the same topic with:
Code Block 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
Install and run HiveMQ service: Install HiveMQ service on Windows
Enable MonitoringEnabling basic and advanced monitoring: Enable monitoring on Windows
Install HiveMQ License: Install HiveMQ license on Windows
Opening required ports in Microsoft Windows Defender Firewall: https://hivemq.atlassian.net/wiki/x/ZgD1pw