-
-
Notifications
You must be signed in to change notification settings - Fork 132
MQTT bridge remote
// repository owner comment: this page was contributed by a user, content is not checked/verified
This chapter describes how to use a local mosquitto broker to exchange MQTT messages with another remote MQTT broker.
In order to use an existing MQTT broker to exchange MQTT messages between the two systems one can bridge the local mosquitto to an upstream MQTT broker. The example configuration snippet below (to be placed in /etc/mosquitto/conf.d
) creates a bridge to a RabbitMQ broker. This approach might also be a solution if ebusd is not able to use the RabbitMQ broker directly.
# example configuration for bridging a RabbitMQ broker using a _non-encrypted_ connection
connection Rabbit
# If try_private is set to true, the bridge will attempt to indicate to the remote broker that it is a bridge not an ordinary client.
# If successful, this means that loop detection will be more effective and that retained messages will be propagated correctly.
# Not all brokers support this feature so it may be necessary to set try_private to false if your bridge does not connect properly.
try_private false
# RabbitMQ server configuration, change IP address and add username/password if necessary
address RABBITMQ_SERVER_IP_OR_HOSTNAME
remote_clientid mosquitto_krypton
remote_username RABBITMQ_USERNAME
remote_password RABBITMQ_PASSWORD
# MQTT tweaks (works for me(tm))
bridge_attempt_unsubscribe false
bridge_protocol_version mqttv311
bridge_insecure true
# forward ebusd MQTT messages between mosquitto server and RabbitMQ server
# using prefix 'krypton' on RabbitMQ server instance
# Note: in this example 'krypton' is the hostname of a host running
# ebusd service allowing us to easily distinguish between multiple sources
topic # both 2 ebusd/ krypton/ebusd/
Replace RABBITMQ_SERVER_IP_OR_HOSTNAME
, RABBITMQ_USERNAME
, RABBITMQ_PASSWORD
and prefix krypton with values matching your environment. Save configuration snippet e.g. as /etc/mosquitto/conf.d/rabbit.conf
and restart mosquitto server.
See also Mosquitto Manual for details on used configuration settings above.