Generic MQTT-TCP Using Mosquitto
You can connect and send messages to an outside message broker from a generic MQTT-TCP message broker.
In the following use case, the Eclipse Mosquitto message broker is used as the selected outside message broker.
Mosquitto is a lightweight open source message broker that Implements MQTT versions 3.1.0, 3.1.1, and version 5.0.
Before You Begin
You must download the Mosquitto message broker. See the Mosquitto Download page to learn more.
To verify that Mosquitto is running in Windows, open up a command prompt and type 'netstat -an'. If your server is running, you should be able to see the port 1883. If you cannot, open Task Manager > Services and start/restart the Mosquitto server from there.
Step 1: Add Generic MQTT Connector
Follow the steps to Add a Connector and select the MQTT - Generic provider.
Configure the following parameters.
- Name: A recognizable name to identify the connector.
- Hostname: Mosquitto is running locally on your PC, so enter your IP address.
- Port: Confirm that the default value 1883 is entered.
- Client ID: Enter 1.
- Username (Optional)
- Password (Optional)
- QoS: Make sure the default value 0 is entered.
- Parallel Publish Count: Enter 100. The number of messages being published simultaneously. Once the defined limit has been reached, subsequent messages are silently dropped. The default value is 100.
- Integration Topic: Enter mos_topic_1.
- LWT topic: The topic for MQTT's Last Will and Testament feature.
- LWT payload: The payload for MQTT's Last Will and Testament feature.
- LWT payload type: The payload type for MQTT's Last Will and Testament feature. The options are string and base64.
- LWT QoS: The Quality of Service value for MQTT's Last Will and Testament feature.
- LWT retained: Select this check box to retain the value for MQTT's Last Will and Testament feature.
- Throttling limit: The maximum number of messages per second to be processed. The default value is zero, which means that there is no limit.
- Persistent storage: When enabled, this will cause messages to undergo a store-and-forward procedure. Messages will be stored within Belden Horizon Data Operations when cloud providers are online.
Step 2: Add Outbound/Inbound Topic to Connector
To add the outbound and inbound topics to the MQTT connector:
- Navigate to Integration.
- Click the MQTT - Generic connector tile.
- Click the Topics tab.
- Configure the following parameters.
- Data Direction: Select Local to Remote - Outbound.
- Local Data Topic: Enter a local data topic.
- Remote Data Topic: Confirm the topic where the data is pushed. This is the Integration Topic value for the connector.
- Enable: Select the toggle to enable the topic.
- Click Yes to add the topic.
- Click the Add a new subscription icon again to add the inbound topic.
- Configure the following parameters.
- Data Direction: Select Remote to Local - Inbound.
- Local Data Topic: Enter integration.raw.Mos_topic_1.
- Remote Data Topic: Confirm the topic where the data is pushed. This is the Integration Topic value for the connector.
- Enable: Select the toggle to enable the topic.
- Click Yes to add the topic.
Step 3: Enable the MQTT - Generic Connector
To enable the connector:
- Return to the Belden Horizon Data Operations Integration browser tab.
Step 4: Create Flow to Verify Connection
To create the flow:
- In Belden Horizon Data Operations, navigate to Flows Manager.
- Double click the DataHub Subscribe node. The Edit DataHub Subscribe Node dialog box appears.
- In the Topic field, enter integration.raw.Mos_topic_in.
- If needed, click the Edit icon for the Datahub field, update the IP Address and Port, and click Add.
- Click Done.
- Double-click the Inject node. The Edit Inject Node dialog box appears.
- In the msg.payload field, select string.
- In the msg.topic field, enter integration.raw.Mos_topic_in.
- Enter test in the Name field, and then click Done.
- Click Deploy to save the flow.





