Kepware Knowledge Base: Solution
Can I Set up a Mosquitto MQTT Broker to Receive KEPServerEX IoT Gateway Messages?
Last Update: 3/18/2019
Yes!
Setting up a Mosquitto MQTT Broker to Receive KEPServerEX IoT Gateway Messages
The KEPServerEX IoT Gateway Plug-in does not include an MQTT broker. A third-party broker, such as Mosquitto, may be configured to receive messages from the IoT Gateway Plug-in agent. Follow these instructions to setup Mosquitto on a Microsoft Windows computer or refer to the vendor instructions.
Tip: The Mosquitto broker may be installed on the machine running KEPServerEX and the IoT Gateway Plug-in.
Prerequisites:
Mosquitto relies on the Microsoft C++ 2015 resdistributable. The following should be installed before Mosquitto according to its documentation:
- Microsoft Visual C++ 2015 Redistributables
- Link: http://www.microsoft.com/en-us/download/details.aspx?id=48145
- Install vcredist_x86.exe
Installation:
Install Mosquitto.
- Link http://mosquitto.org/download/
- Install the Windows Binary mosquitto-<version>-install-win32.exe (Native build, Windows Vista or higher)
Running Mosquitto:
- To start the broker, open a command prompt by clicking on Start | All Programs | Accessories | Command Prompt.
- In the command prompt, navigate to the Mosquitto root folder, such as C:\Program Files (x86)\mosquitto.
- Start the Mosquitto service by running the command: "net start mosquitto".
- Acknowledge the message: The Mosquitto Broker service was started successfully.
Connecting to the Mosquitto Broker:
- Follow the steps in the KEPServerEX IoT Gateway Plug-in help system to setup an MQTT agent.
- In the agent, the URL is tcp://<IP of the broker machine>:1883.
- Set the topic (user configurable).
- Set the publish rate to a reasonable number, such as 1000ms.
- Add a tag to the agent. This tag should change value at least once per the publish interval set in step 4 or be configured to send "every scan" to confirm function.
- Once the tag is added, confirm this event log message in KEPServerEX Configuration interface: "MQTT agent <agent> is connected to broker 'tcp://<IP of the broker machine>:1883'"
Verifying the Data:
- Open a command prompt by clicking on Start | All Programs | Accessories | Command Prompt.
- In the command prompt, navigate to the Mosquitto root folder, such as C:\Program Files (x86)\mosquitto.
- Start the Mosquitto subscription service by running the command: "mosquitto_sub.exe -t #" where " t #" instructs the mosquitto_sub program to display data published to all topics on the Mosquito broker.
- Verify the data IoT Gateway Plugin is publishing to the Mosquitto Broker appears in the command window.
Congratulations!
©
2021
PTC Inc. All Rights Reserved.