---
title: Generic MQTT-TCP Using HiveMQ
slug: bhdo/generic-mqtt-tcp-using-hivemq
createdAt: 2022-11-28T21:04:44.000Z
---

You can connect and send messages to an outside message broker from a generic MQTT-TCP message broker.

In the following use case, the HiveMQ message broker is used as the selected outside message broker.

HiveMQ's MQTT broker is designed for cloud native deployments to make optimal use of cloud resources. The use of MQTT reduces network bandwidth required for moving data.

# Before You Begin

You must download [MQTT Explorer](http://mqtt-explorer.com/).

Visit the [MQTT Dashboard](http://www.mqtt-dashboard.com/) to find the settings required in the MQTT Explorer application.

# Step 1: Connect MQTT Explorer

**To connect MQTT Explorer:**

1. Open MQTT Explorer.
2. Click the **Add&#x20;**&#x69;con to create a new connection.&#x20;
3. In the **Name** field, enter a name for the connection.&#x20;
4. In the **Host&#x20;**&#x66;ield, enter **broker.hivemq.com**.&#x20;
5. In the Port field, verify that **1883&#x20;**&#x69;s entered.&#x20;
6. Click **CONNECT**.
   The connection appears in the left pane.

# Step 2: Add Generic MQTT Connector

Follow the steps to [Add a Connector](https://public-docs.litmus.io/bhdo/add-a-connector) and select the **MQTT - Generic&#x20;**&#x70;rovider.&#x20;

Configure the following parameters.&#x20;

- **Name**: A recognizable name to identify the connector.&#x20;
- **Hostname**: Enter **broker.hivemq.com**.&#x20;
- **Port**: Confirm that the default value **1883** is entered.&#x20;
- **Client ID**: Enter a client ID.&#x20;
- **Username&#x20;**(Optional)
- **Password&#x20;**(Optional)
- **QoS**: Make sure the default value **0** is entered.&#x20;
- **Parallel Publish Count**: Enter **100**. The number of messages being published simultaneously. Once the defined limit has been reached, subsequent messages are silently dropped.&#x20;
- **Integration Topic**: Enter a topic name. For example: **mqtt\_topic**.&#x20;
- **LWT topic**: The topic for MQTT's Last Will and Testament feature.&#x20;
- **LWT payload**: The payload for MQTT's Last Will and Testament feature.&#x20;
- **LWT payload type**: The payload type for MQTT's Last Will and Testament feature. The options are *string&#x20;*&#x61;nd *base64*.&#x20;
- **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.&#x20;
- **Throttling limit**: The maximum number of messages per second to be processed. The default value is zero, which means that there is no limit.&#x20;
- **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. &#x20;

# Step 3: Create Topics for MQTT Connector

**To add the outbound and inbound topics to the MQTT Connector:**

1. Navigate to **Integration**.&#x20;
2. Click the *MQTT - Generic&#x20;*&#x63;onnector tile.&#x20;
3. Click the **Topics&#x20;**&#x74;ab.&#x20;
4. Click the **Add a new subscription** icon.&#x20;
   The *Data Integration&#x20;*&#x64;ialog box appears.&#x20;

   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/Waj7kiDNAMWSsraFzrNss_addanewsubscription.png" size="80" width="1148" height="570" caption="Add a new subscription icon" position="center" showCaption="true"}
5. Configure the following parameters.&#x20;
   - **Data Direction**: Select **Local to Remote - Outbound**.&#x20;
   - **Local Data Topic**: Enter a local data topic name.&#x20;
   - **Remote Data Topic**: Confirm the topic where the data is pushed. This is th&#x65;*&#x20;Integration Topic&#x20;*&#x76;alue for the connector.&#x20;
   - **Enable**: Select the toggle to enable the topic.&#x20;
6. Click **Yes&#x20;**&#x74;o add the topic.&#x20;
7. Click the **Add a new subscription** icon again to add the inbound topic.
8. Configure the following parameters.&#x20;
   - **Data Direction**: Select **Remote to Local - Inbound**.
   - **Local Data Topic**: Enter a local data topic name. For example: **local\_topic**. &#x20;
   - **Remote Data Topic**: Confirm the topic where the data is pushed. This is th&#x65;*&#x20;Integration Topic&#x20;*&#x76;alue for the connector.&#x20;
   - **Enable**: Select the toggle to enable the topic.&#x20;
9. Click **Yes&#x20;**&#x74;o add the topic.&#x20;

# Step 4: Enable the MQTT Connector

**To enable the connector:&#x20;**

1. Return to the *Belden Horizon Data Operations Integration* browser tab.
2. Click the connection toggle on the connector tile.&#x20;
   The connector shows connected after verifying the connection.

   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/3BjHvFfmrBXUwRLDUWEBg_mqttgenerica.png" size="60" width="359" height="265" caption="Toggle to enable connector" position="center" showCaption="true"}

# Step 5: Verify Connection in MQTT Explorer

You can verify the connection in MQTT Explorer by subscribing to the topics for the connector.

**To verify the connection:**

1. Open MQTT Explorer.&#x20;
2. Click **DISCONNECT**.&#x20;
3. Select the connection you created earlier.&#x20;
4. Click **ADVANCED**.&#x20;
5. In the Topic field, enter the Integration Topic value you configured in Step 2. In this use case, the value is **mqtt\_topic**.&#x20;
6. Verify the QoS value is **0**.&#x20;
7. Click **+ADD**.&#x20;
8. Click **BACK**.&#x20;
9. Click **SAVE**, and then **CONNECT**.&#x20;

Verify that data is being displayed.&#x20;

