Skip to content

MQTT Bridge Asset

The MQTT Bridge is a flux asset provided by Coreflux that facilitates the seamless communication between two MQTT brokers. This guide offers a comprehensive overview of the MQTT Bridge, detailing its features, benefits, installation, configuration, and usage.

Introduction

What is MQTT Bridge?

The MQTT Bridge is designed to act as a conduit between two MQTT brokers, allowing messages from one broker (Source) to be replicated and forwarded to another broker (Destination). This is particularly useful in scenarios where data from one MQTT network needs to be shared with another network without direct integration.

Features and Benefits

  • Broker-to-Broker Communication: Enables seamless communication between two MQTT brokers.
  • Data Replication: Replicates data from the source broker to the destination broker.
  • Flexible Configuration: Allows for custom configurations to define source and destination parameters.
  • Secure Communication: Supports TLS for encrypted communication and authentication.

Prerequisites

Before you install and configure the MQTT Bridge, ensure you have:

  • Basic understanding of the MQTT protocol.
  • Coreflux account.
  • Coreflux v1.2 or higher.
  • Coreflux MQTT Broker asset.
  • MQTT Client (such as MQTT Explorer).

Installation

Method 1: GUI

// Instructions for GUI installation

Method 2: Command-line

// Instructions for command-line installation

Configuration

To configure the MQTT Bridge, you need to run the following command:

-assetConfigSave <guid> <configuration>
  • <guid>: A unique asset id generated during the installation. To obtain the asset guid, refer to the $SYS/Coreflux/Assets topic.
  • <configuration>: The asset settings in JSON format.

Parameters

Source Parameters

These parameters configure the MQTT Client that acts as the source:

  • ClientID: A custom identifier for the source MQTT Client.
  • Address: MQTT broker address.
  • Port: MQTT broker port.
  • SubscribeQoS: Quality of Service (QoS) level for subscribing to MQTT topics.
  • Username: MQTT client username.
  • Password: MQTT client password.
  • EnableAuthentication: Indicates if authentication is required to connect to the broker.
  • EnableTLS: Enables a secure connection using Transport Layer Security (TLS).
  • PublishWithRetain: Indicates if messages on the "Topic" should be retained.
  • AutoRestart: Indicates if the client should automatically reconnect to the broker upon disconnection.
  • PublishQoS: Quality of Service (QoS) level for publishing MQTT messages.
  • Topic: The topic the "Source" client subscribes to and wants to replicate to the "Destination" client.

Destination Parameters

These parameters configure the MQTT Client that acts as the destination:

  • ClientID: A custom identifier for the destination MQTT Client.
  • Address: MQTT broker IP Address.
  • Port: MQTT broker port.
  • SubscribeQoS: Quality of Service (QoS) level for subscribing to MQTT topics.
  • Username: MQTT client username.
  • Password: MQTT client password.
  • EnableAuthentication: Indicates if authentication is required to connect to the broker.
  • EnableTLS: Enables a secure connection using Transport Layer Security (TLS).
  • PublishWithRetain: Indicates if messages on the "Topic" should be retained.
  • AutoRestart: Indicates if the client should automatically reconnect to the broker upon disconnection.
  • PublishQoS: Quality of Service (QoS) level for publishing MQTT messages.
  • Topic: The topic or prefix the destination MQTT client will publish to.

Example Configuration

{
  "Source": {
    "ClientID": "1",
    "Address": "192.168.100.31",
    "Port": 1883,
    "SubscribeQoS": 0,
    "Username": "",
    "Password": "",
    "EnableTLS": false,
    "EnableAuthentication": true,
    "PublishWithRetain": false,
    "AutoRestart": true,
    "PublishQoS": 0,
    "Topic": "Coreflux/1"
  },
  "Destination": {
    "ClientID": "12",
    "Address": "127.0.0.1",
    "Port": 1883,
    "SubscribeQoS": 0,
    "Username": "",
    "Password": "",
    "EnableTLS": false,
    "EnableAuthentication": true,
    "PublishWithRetain": false,
    "AutoRestart": true,
    "PublishQoS": 0,
    "Topic": "Coreflux/S7Asset/DebugTopic"
  }
}

Running the Asset

To run the MQTT Bridge, publish the “-R” (run) command with the asset guid to the $SYS/Coreflux/Cloud/Command topic:

-R <guid>

Once executed, the asset will start, and data will flow from the source to the destination broker.

Usage

With the MQTT client, you can now visualize and monitor the data being replicated between the two brokers.

FAQ

General Questions

What is the MQTT Bridge Asset?

The MQTT Bridge Asset is a flux asset provided by Coreflux that enables seamless communication between two MQTT brokers. It allows for the replication of data from a source broker to a destination broker, facilitating data sharing between two separate MQTT networks.

What are the prerequisites for using the MQTT Bridge Asset?

Before you install and configure the MQTT Bridge, ensure you have: - Basic understanding of the MQTT protocol. - Coreflux account. - Coreflux v

1.2 or higher. - Coreflux MQTT Broker asset. - MQTT Client (such as MQTT Explorer).

How do I install the MQTT Bridge Asset?

The MQTT Bridge Asset can be installed via GUI or command-line. Detailed installation instructions can be found in the Installation section.

Configuration Questions

How do I configure the MQTT Bridge Asset?

To configure the MQTT Bridge, you need to run the following command:

-assetConfigSave <guid> <configuration>
The <guid> is a unique asset id generated during the installation. The <configuration> parameter is where you set the asset settings. Detailed configuration instructions and an example configuration can be found in the Configuration section.

What are the parameters in the configuration?

The configuration consists of two main sections: Source and Destination. - Source parameters configure the MQTT Client acting as the source. - Destination parameters configure the MQTT Client acting as the destination. A detailed explanation of all parameters can be found in the Configuration section.

Usage Questions

What are the potential issues with different QoS levels?

Different QoS levels affect the message delivery guarantees and the network bandwidth usage. For example, using QoS 2 (ExactlyOnce) ensures that the message is delivered exactly once, but it requires more network bandwidth and increases the latency. On the other hand, using QoS 0 (AtMostOnce) uses less network bandwidth but does not guarantee the message delivery. It is important to choose the QoS level that best suits your use case and network conditions.

What are the benefits of having different models of information?

Having different models of information allows you to optimize the data flow and storage. For example, you can have a broker for a machine that handles signals of the machine, and a bridge to a broker that handles all the data of the factory. The machine broker can use a lightweight data model with minimal overhead, while the factory broker can receive messages with detailed information like JSON, contextualization, or models. This separation of concerns helps to optimize the performance and the storage requirements.

Can I use the MQTT Bridge asset to connect to brokers with different security settings?

Yes, the MQTT Bridge asset supports different security settings for the source and the destination brokers. You can configure the EnableTLS, EnableAuthentication, Username, and Password parameters for each broker independently.

Can I replicate messages from multiple topics?

Yes, you can replicate messages from multiple topics by specifying a topic prefix or a wildcard in the Topic parameter of the Source configuration. For example, specifying Coreflux/1/# will replicate messages from all topics that start with Coreflux/1/.

Can I replicate messages to multiple destinations?

The current version of the MQTT Bridge asset supports only one destination broker. However, you can install and configure multiple instances of the MQTT Bridge asset to replicate messages to multiple destinations.

How do I run the MQTT Bridge Asset?

To run the MQTT Bridge, publish the “-R” (run) command with the asset guid to the $SYS/Coreflux/Cloud/Command topic:

-R <guid>
Once executed, the asset will start, and data will flow from the source to the destination broker.

How can I visualize the data?

Using an MQTT client, you can visualize and monitor the data being replicated between the two brokers. Detailed usage instructions can be found in the Usage section.

Troubleshooting Questions

The MQTT Bridge Asset is not running, what should I do?

Ensure that you have correctly installed and configured the MQTT Bridge Asset. Check the $SYS/Coreflux/Assets topic to confirm that the asset guid is correct. If the problem persists, consult the troubleshooting section or join our Discord community for help.

I am not receiving any data, what should I do?

Ensure that the MQTT Bridge Asset is running and that both the source and destination MQTT clients are correctly configured. If the problem persists, consult the troubleshooting section or join our Discord community for help.