Skip to main content

MQTT Bridge Overview

The MQTT_BRIDGE connector connects your Coreflux broker to another MQTT broker and keeps selected topics in sync between them. Use it for edge-to-cloud synchronization, linking multiple sites, or mirroring data to a backup broker.
Like call forwarding for messages. You decide which topics get forwarded and in which direction, and the bridge relays every matching message between the two brokers automatically.

When to use it

  • Push local sensor data from an edge device up to a cloud broker.
  • Pull commands or configuration from a central broker down to remote sites.
  • Keep two brokers continuously in sync for redundancy.

Let’s look at how to define a bridge, starting with the most common scenarios.

Quick Start

Forward local sensor data up to a cloud broker over TLS:

Connection Configuration

A bridge has two sides, ADD SOURCE_CONFIG and ADD DESTINATION_CONFIG. Each side is either this broker (WITH BROKER SELF) or a remote broker set with BROKER_ADDRESS. Either side can be SELF. On a SELF side, the block’s other settings are ignored.

Source, destination and direction

Each remote side gets its own MQTT client, which subscribes to that side’s topic. A SELF side has no client: the bridge reads the topic from this broker.
  • out forwards source → destination: it reads SOURCE_TOPIC and publishes to DESTINATION_TOPIC.
  • in forwards destination → source: it reads DESTINATION_TOPIC and publishes to SOURCE_TOPIC.
  • both does both. It is the default when a mapping leaves DIRECTION out.

Login is optional

Leave USERNAME and PASSWORD out for a broker that needs no login. That side then connects without credentials. CLIENT_CERT_PASS is needed only when the client key is encrypted. -addConnector refuses a bridge, with a message that names the setting, when a side:
  • is not WITH BROKER SELF and has no BROKER_ADDRESS, or
  • sets PASSWORD without USERNAME.
A GET SECRET or GET ENV value counts as set when you add the connector. It is resolved when the connector starts.
string
Set to SELF (WITH BROKER SELF) to use this broker for this side. The block’s other settings are then ignored.
string
IP address or hostname of the remote broker. Required unless the side is WITH BROKER SELF.
integer
MQTT port of the remote broker. Default: 1883. TLS brokers usually listen on 8883.
string
Client identifier for the bridge connection. Optional. When unset, the broker generates one that is unique per host, connector and endpoint (cf-<host>-<connector>-src or cf-<host>-<connector>-dst). Set it when the remote broker expects a specific client ID, and keep it distinct for each connector.
string
Login user name. Leave it out for a broker that needs no login.
string
Login password. Needs USERNAME. Use GET SECRET to keep it out of the connector definition.
boolean
Enable TLS encryption. Default: false.
boolean
Allow untrusted certificates. Default: false.
string
Path to CA certificate file.
string
Path to client certificate for mTLS, or a combined PEM with certificate and key.
string
Path to a separate private key file. Leave it out when CLIENT_CERT_PATH is a combined PEM.
string
Password of an encrypted client key. Leave it out when the key is not encrypted.
integer
Number of reconnection attempts. Default: 5.

When the remote broker is slow to answer

Adding a bridge waits at most 5 seconds for a remote broker to accept the connection before the command replies. A remote broker that answers in time is connected when the reply arrives. One that is slow or silent keeps connecting in the background, and a failure is logged when it happens. Other broker commands are not held up meanwhile.

Mapping Configuration

Each ADD MAPPING block defines which topics are bridged and in which direction.
string
required
Topic on the source side. Read for out, written for in. Supports + and # wildcards.
string
required
Topic on the destination side. Written for out, read for in. Supports + and # wildcards.
string
Data flow direction: out (source → destination), in (destination → source), or both. Default: both.

QoS and RETAIN

The bridge forwards each message, in either direction, with the QoS and RETAIN flag it was published with. A retained message becomes retained on the other broker, and clearing it there (an empty retained publish) clears the bridged copy too. QoS 1 and QoS 2 messages keep their delivery guarantee on the forwarded hop. A subscriber still receives at most the QoS of its own subscription, as MQTT specifies. There is no mapping setting to change QoS or RETAIN; the publisher’s values always apply.
The receiving broker’s limits win. If a remote broker accepts at most QoS 1, or does not support retained messages, the bridge publishes at that maximum QoS and without RETAIN instead of being disconnected. Some cloud MQTT services allow at most QoS 1.
Retained messages replay on every reconnect. Each time the bridge connects, the remote broker sends it every retained message under the mapped topics, and the bridge forwards them as retained. A change made on the local broker while the link was down is not forwarded, so for in and both mappings the remote’s older retained value can replace the newer local one. A # mapping replays the whole retained tree. Keep each retained topic owned by one side, or republish it after the link recovers.
Each bridge connection keeps up to 64 QoS 1/2 publishes waiting for an acknowledgement at once. When a slow remote broker fills all 64, other connectors’ queued updates wait too, and each connector’s overload policy decides whether its producers wait or drop.

Secure mTLS Bridge

For production links between sites, encrypt both endpoints and authenticate with mutual TLS:

Best Practices

Always enable TLS when connecting to external brokers:
If you set CLIENT_ID, keep it unique per bridge connection to avoid conflicts. Two connections with the same client ID on one remote broker disconnect each other. Leave it unset to use the generated default.
Use WITH BROKER SELF during development:
Store passwords securely and use app-specific passwords where available.
Configure appropriate retry settings:

Troubleshooting

  • Verify IP address and port are correct
  • Check firewall allows outbound connections on the configured port
  • Ensure remote broker is running and accessible
  • Try increasing RECONNECTION_RETRIES
  • The add command replies after at most 5 seconds even if the remote broker has not answered. Check the broker log for the connection result. See When the remote broker is slow to answer
  • The reply names the side and the setting
  • Give each remote side a BROKER_ADDRESS, or use WITH BROKER SELF
  • Set USERNAME with PASSWORD, or leave both out for a broker that needs no login
  • Check USERNAME and PASSWORD for that side
  • A GET SECRET with no value on this broker is sent as no password. Check the secret exists with -listSecrets
  • Verify certificate paths are correct
  • Ensure certificates are valid and not expired
  • Check certificate chain is complete
  • For testing, use ALLOW_UNTRUSTED_CERTS "true" (not recommended for production)
  • Verify SOURCE_TOPIC and DESTINATION_TOPIC are correct
  • Check DIRECTION setting matches your expected data flow
  • If you set CLIENT_ID, ensure it is unique across all connections
  • Check broker logs for subscription errors
  • The remote broker replays its retained messages each time the bridge connects. See QoS and RETAIN
  • Keep each retained topic owned by one broker, or republish the current value after the link recovers

Next Steps

System Connectors

Compare bridging and Sparkplug roles.

Sparkplug B

Publish and consume structured industrial MQTT data.
Last modified on December 4, 2026