An MQTT bridge is a broker-to-broker connection that forwards messages between two MQTT brokers based on defined topic rules. It links separate networks or sites, for example an edge broker and a cloud broker, and keeps each broker running as its own independent system.
MQTT Bridge: Key Takeaways
- An MQTT bridge connects two MQTT brokers through a broker-configured MQTT client connection and forwards messages based on topic rules you configure.
- Bridge direction settings (in, out, or both) combined with local and remote topic prefixes control which messages cross the bridge and help reduce the risk of messages looping back and forth.
- TLS encryption and dedicated bridge credentials help protect traffic between sites, while local message queuing can buffer eligible data during an outage, subject to queue limits and persistence settings.
- Cedalo’s Pro Mosquitto broker adds clustering and centralized bridge monitoring through the Management Center, giving IT and OT teams one interface for supported bridge connections.
What Is an MQTT Bridge?
In Mosquitto, an MQTT bridge is a built-in broker feature that connects to another broker through a broker-managed MQTT client connection. You configure it inside the broker’s own configuration file, alongside the broker’s other settings.
How Does an MQTT Bridge Differ from an MQTT Broker?
A broker is the server that accepts client connections, manages subscriptions, and routes messages between publishers and subscribers. An MQTT bridge, also called an MQTT broker bridge, is the separate link that connects two of these brokers to each other. The broker keeps serving its own clients. The bridge only carries the topics you choose to forward between the two brokers.
How Does an MQTT Bridge Work?
One broker, the local broker, opens an outbound connection to a second broker, the remote broker, and exchanges messages for a defined set of topics. The bridge forwards only the configured topics, while devices on each side keep publishing and subscribing to their own broker as usual.
A bridge configuration defines three things: the remote broker’s address, the topics to forward, and the direction of that forwarding. This setup runs once, at the broker level, so no device needs to know a bridge exists.
When Do You Need an MQTT Bridge? Common Use Cases
A bridge earns its place whenever devices, applications, or sites publish to separate brokers that still need a shared view of the data. Three deployment patterns cover most production setups:
1. Edge-to-Cloud Bridging
A local broker runs close to the machines on a factory floor or in a vehicle, and a bridge forwards a filtered set of topics to a cloud broker for analytics and long-term storage. Local control loops keep working even if the internet connection drops, since the bridge only affects the forwarded topics.
2. Multi-Site and Multi-Broker Architectures
Manufacturing groups with several plants often run one broker per site and bridge selected topics into a central broker. Site-level traffic stays local, and headquarters still gets a consolidated feed of production data through the bridged topics alone.
3. Using Protocol Gateways Before MQTT Bridging
Not every source speaks MQTT natively. An OPC UA server on a production line, or a legacy system that only exposes an HTTP API, typically needs a protocol gateway to translate its data into MQTT topics first. Similarly, device-level integrations like Zigbee2MQTT, Govee-to-MQTT, or MeshCore bridges act as application-level translators that convert proprietary Bluetooth, RF, or vendor APIs into standard MQTT payloads. Once that data lands on a local broker, a standard bridge carries it onward to a remote broker, so the OPC UA or HTTP layer only has to integrate once.
How Do You Configure an MQTT Bridge in Mosquitto?
A Mosquitto bridge configuration lives in a dedicated connection block that defines the remote broker, the topics to forward, and the credentials to use for that connection.
Core Bridge Parameters
The minimum configuration needs a connection name, the remote broker’s address, and at least one topic line. A port can be specified when required. The topic line sets the direction, QoS level, and local and remote topic prefixes.
connection bridge-to-cloud
address cloud-broker.example.com:8883
topic sensors/# out 1 "" site-a/
topic commands/# in 1 local/ site-a/
Topic Mapping and Bridge Direction
The local and remote prefixes in the topic line determine how a topic is renamed as it crosses the bridge. Using "" (an empty string) means no prefix is added or stripped on that side. In the example above, a message published locally to sensors/temp is forwarded outbound (out) to the remote broker as site-a/sensors/temp. Conversely, a message published to site-a/commands/reboot on the remote broker is routed inbound (in) and stripped down to local/commands/reboot on the edge broker. This mapping keeps traffic from multiple sites distinguishable on a shared broker and helps prevent messages from being forwarded back toward their source.
How Do You Prevent Message Loops and Duplicate Data?
A loop can happen when overlapping bridge mappings forward a message back toward the broker it originally came from. Distinct local and remote topic prefixes reduce this risk, while a unique local_clientid prevents client ID conflicts. Where supported, setting try_private true improves bridge loop detection by setting a dedicated bit in the MQTT protocol version header, signaling to a remote Mosquitto broker that the connection is a bridge so it will not echo retained messages back. Important vendor caveat: Non-Mosquitto brokers (such as AWS IoT Core, HiveMQ, or EMQX) often reject this modified protocol header as invalid. Always set try_private false when bridging to third-party brokers.
Prefixes that keep site-specific topics from overlapping on the shared broker can also reduce duplicate messages.
How Do You Secure an MQTT Bridge?
Bridge traffic between sites needs the same protection as any other connection that carries production data across a public or semi-public network.
TLS Encryption for Bridge Connections
When TLS and certificate validation are configured correctly, using a certificate authority file and optionally client certificates, traffic crossing the bridge is encrypted in transit.
Authentication and Access Control
Bridge connections should use a dedicated username and password, separate from any device credentials, scoped only to the topics the bridge actually forwards through access control lists.
Bridge credentials and topic permissions are easy to misconfigure once several teams manage different sites.
Keep Bridge Credentials Consistent Across Every Site
Manage supported bridge users, certificates, and topic permissions from one interface to help reduce inconsistent or outdated credentials across sites.
Production-Ready Bridge Configuration Example
For production deployments requiring TLS encryption, persistent offline queuing, and dedicated credentials, combine the routing rules with security and session parameters:
connection prod-edge-to-central
address central-broker.example.com:8883
# Routing & Loop Prevention
topic telemetry/# out 1 "" plant-berlin/
topic config/# in 1 "" plant-berlin/
local_clientid bridge-plant-berlin-01
try_private true
# Offline Session & Queue Behavior
cleansession false
restart_timeout 5 30
# Authentication & TLS Security
remote_username bridge_berlin_user
remote_password StrongBridgePassword!
bridge_cafile /etc/mosquitto/certs/ca.crt
bridge_tls_version tlsv1.3
What each parameter does:
- connection & address: Defines a unique internal name for the bridge and points to the remote broker’s hostname and TLS port (8883).
- topic telemetry/# out 1 "" plant-berlin/: Forwards all local telemetry/# messages outbound at QoS 1, prepending plant-berlin/ on the remote broker.
- topic config/# in 1 "" plant-berlin/: Subscribes to plant-berlin/config/# on the remote broker at QoS 1 and strips the plant-berlin/ prefix before publishing locally.
- local_clientid: Assigns a fixed, unique client ID so the remote broker can track the bridge’s session state across reconnects.
- try_private true: Signals to a remote Mosquitto broker that this client is a bridge so retained messages are not echoed back (set to false for non-Mosquitto brokers).
- cleansession false: Preserves subscriptions and queued QoS 1/2 messages on both brokers while the bridge connection is offline.
- restart_timeout 5 30: Uses exponential backoff on reconnect attempts, starting at 5 seconds and capping at 30 seconds to avoid flooding the network during outages.
- remote_username & remote_password: Authenticates the bridge against the remote broker using dedicated bridge credentials.
- bridge_cafile & bridge_tls_version: Verifies the remote broker’s server certificate against a trusted Certificate Authority (CA) and enforces TLS 1.3 encryption.
What Happens When a Bridge Connection Goes Offline?
A bridge connection can drop for the same reasons any network link fails: a site loses internet access, a firewall rule changes, or a remote broker restarts. What happens to your data during that gap depends on two settings.
Message Queuing and QoS During Outages
Messages published at QoS 1 or 2 on topics with a persistent bridge session can be queued locally within configured limits until the connection returns. However, by default, Mosquitto holds queued messages in memory (up to max_queued_messages, default 1,000). To ensure buffered bridge data survives a local broker restart or power loss during an outage, you must enable disk persistence (persistence true) in your global broker settings. Setting cleansession false also instructs the remote broker to queue inbound (in) messages for the bridge while it is disconnected.
MQTT ordering and duplicate-delivery rules still apply, as defined in the OASIS MQTT specification. By default, QoS 0 messages published during an outage are not queued, so important data normally requires at least QoS 1 throughout the delivery path.
Failover and High Availability Patterns
For connections that require high availability, pairing the bridge with a clustered broker on the remote end reduces the risk of a single broker node becoming a point of failure.
How Do You Monitor and Troubleshoot an MQTT Bridge in Production?
A healthy bridge shows a stable connection status and a steady message rate on both ends. When a bridge misbehaves, check the broker log first. Repeated connect and disconnect entries usually point to a network issue or a client ID conflict. Authentication or authorization errors can indicate problems with credentials, certificates, ACLs, plug-ins, or related settings.
A short checklist covers most production issues:
- Confirm the bridge shows as connected on both the local (Logs) and remote (is shown as a regular MQTT client) brokers.
- Compare message counts on the local and remote topics to spot silent message loss.
- Check for duplicate local_clientid values if a bridge keeps reconnecting.
- Review certificate expiry dates for any bridge running over TLS.
MQTT Bridge vs. Kafka: Extending Beyond MQTT-to-MQTT Connections
A standard bridge connects two MQTT brokers directly and works well when both ends run MQTT. Once a project needs long-term storage, stream processing, or fan-out to many downstream consumers, teams often add a Kafka integration behind the broker instead of a second bridge target, often as part of a broader Unified Namespace architecture.
| Criterion | MQTT bridge | MQTT-to-Kafka integration |
|---|---|---|
| Best fit | Broker-to-broker forwarding | Storage, stream processing, fan-out |
| Setup effort | Low, native broker feature | Higher, needs a connector |
| Message retention | No general-purpose replayable log; temporary buffering depends on broker, session, and queue settings | Configurable, often days or weeks |
Build a Reliable MQTT Bridge Setup
An MQTT bridge gives you a broker-native way to move data between sites, edge and cloud environments, or separate broker instances. Getting it right comes down to a handful of settings: correct topic direction and prefixes to avoid loops, TLS and dedicated credentials to keep traffic secure, and enough QoS and queuing to survive a dropped connection.
Your advantages with Cedalo:
- You configure and monitor supported bridge connections from one Management Center instead of editing configuration files on each broker separately.
- You can add clustering and high availability to the broker on either end of a bridge without changing the bridge configuration when the same stable endpoint remains available.
- You get enterprise support for Eclipse Mosquitto from the team that maintains the open-source project itself.
- You retain compatibility with standard Mosquitto bridge syntax, although version-specific and deprecated options should be validated before migration.
Get a Live Walkthrough of Bridge Management in Pro Mosquitto
A 30-minute session shows how your bridge connections, clustering, and monitoring look inside the Management Center, using your own edge, cloud, or multi-site setup as the example.
MQTT Bridge: Frequently Asked Questions
Can an MQTT bridge connect brokers from different vendors?
Yes, a Mosquitto broker can connect to a broker from another vendor through a standard MQTT client connection. Broker bridging itself is a broker-specific feature and works when the remote broker supports the required MQTT, topic, authentication, and authorization settings.
Can I bridge into a clustered Pro Mosquitto broker?
Yes, a bridge can connect to a Pro Mosquitto cluster through a stable cluster endpoint. With a correctly configured load balancer, individual node failures can be handled without changing the bridge configuration.
What is the difference between an MQTT bridge and a Sparkplug-aware MQTT application?
An MQTT bridge forwards raw MQTT messages based on topic rules, without interpreting their payload. A Sparkplug-aware MQTT application understands the Sparkplug payload format and session state, which matters for use cases that rely on Sparkplug’s birth and death certificates.
Can a MeshCore MQTT integration use the same configuration approach?
Yes, if a MeshCore integration publishes data to an MQTT broker, that broker can forward selected topics to a remote broker using a standard Mosquitto bridge configuration.
Does Cedalo offer support for production MQTT bridge deployments?
Yes, Cedalo provides enterprise support for Pro Mosquitto bridge setups directly from the team that maintains the open-source Eclipse Mosquitto project, covering configuration reviews, troubleshooting, and service level agreements for production environments.
Do I need a static IP address for a bridge to work?
No, a bridge works with a resolvable hostname or a static IP address for the remote broker, though a stable address reduces reconnect issues if the remote broker’s IP changes.