Use the search and browse feature to view Kepware's repository of more than 500 Knowledge Base articles. Narrow your results or type your query into the search field below.

Search Solutions Results By: View All Solutions

Kepware Knowledge Base: Solution


Can I Set up a Mosquitto MQTT Broker to Receive KEPServerEX IoT Gateway Messages?


Last Update: 11/12/2018
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 several third-party packages to install properly. The following should be installed before Mosquitto according to its documentation:
  • Microsoft Visual C++ 2010 Redistributables
    • Link: http://www.microsoft.com/en-us/download/details.aspx?id=5555
    • Install vcredist_x86.exe
  • OpenSSL
    • Link: http://slproweb.com/products/Win32OpenSSL.html
    • Install "Win32 OpenSSL <version>"
    • Use all the default settings in the installer
    • Required DLLs: libeay32.dll ssleay32.dll
  • pthreads
    • Link: ftp://sourceware.org/pub/pthreads-win32
    • No install needed for pthreads-w32-<version>-release.zip
    • Required DLLs: pthreadVC2.dll
Installation:
  1. Install Mosquitto.
    • Link http://mosquitto.org/download/
    • Install Windows Binary mosquitto-<version>-install-win32.exe (Native build, Windows Vista or higher)
  2. Copy the following files from the OpenSSL installation, C:\OpenSSL-Win32, to the Mosquitto root folder, C:\Program Files (x86)\mosquitto:
    • ssleay32.dll
    • libeay32.dll
  3. Copy the following file from the pthreads zip archive to the Mosquitto root folder, C:\Program Files (x86)\mosquitto:
    • pthreads-w32-<version>-release.zip\Pre-built.2\dll\x86\pthreadVC2.dll
Running Mosquitto:
  1. To start the broker, open a command prompt by clicking on Start | All Programs | Accessories | Command Prompt.
  2. In the command prompt, navigate to the Mosquitto root folder, such as C:\Program Files (x86)\mosquitto.
  3. Start the Mosquitto service by running the command: "net start mosquitto".
  4. Acknowledge the message: The Mosquitto Broker service was started successfully.
Connecting to the Mosquitto Broker:
  1. Follow the steps in the KEPServerEX IoT Gateway Plug-in help system to setup an MQTT agent.
  2. In the agent, the URL is tcp://<IP of the broker machine>:1883.
  3. Set the topic (user configurable).
  4. Set the publish rate to a reasonable number, such as 1000ms.
  5. 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.
  6. 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:
  1. Open a command prompt by clicking on Start | All Programs | Accessories | Command Prompt.
  2. In the command prompt, navigate to the Mosquitto root folder, such as C:\Program Files (x86)\mosquitto.
  3. 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.
  4. Verify the data IoT Gateway Plugin is publishing to the Mosquitto Broker appears in the command window.
Congratulations!