Apie
Apie

Reputation: 6431

Verify that local mosquitto MQTT Broker is bridged to test.mosquitto.org

I have a local (OSX 11) mosquitto broker (1.4.7) running with the following config:

connection test
address test.mosquitto.org
topic in_topic in 0
topic out_topic out 0
try_private false
notifications false
bridge_attempt_unsubscribe true

I got the conf settings form here: bridge local mosquitto to cloud broker (thanks)

I now have 3 terminals.

A: subscribed to test.mosquitto.org directly using a ruby script and ruby-mqtt.

B: subscribed to local broker with mosquitto_sub -t in_topic

C: publishes using this command: mosquitto_pub -h test.mosquitto.org -t in_topic -m "hello world1"

Now, when I do this I get the response in A and B so that makes me think my bridging connection is working. However, if I drop the -h test.mosquitto.org I don't get the message from A. So, the message is only going to that broker (test.mosquitto.org) if I include the -h option.

On the other hand, if I stop the local mosquitto broker and then run the same command including the -h option then the A still gets the message and B doesn't. B actually doesn't even start up since the connection is refused since local broker is not running.

So, my question is, does this configuration actually establish that the brokers are bridging? I am not sure.

Update: As hardillb pointed out my mistake was that the topic that I was using to publish was not configured to publish out to the other broker. When I updated the conf to topic in_topic out 0 I succeeded in getting the message directly from the test.mosquitto.org broker without including the -h test.mosquitto.org in other words. The message propagated based on the configuration.

The documentation for what I got wrong can be found under the bridging section here: http://mosquitto.org/man/mosquitto-conf-5.html

Upvotes: 1

Views: 4167

Answers (2)

ralight
ralight

Reputation: 11628

I would change your config if you can:

notifications true

This will publish to $SYS/broker/connections//state - either a 1 or 0 depending on whether the connection is active. This happens on both the remote and the local broker.

Upvotes: 0

hardillb
hardillb

Reputation: 59826

You won't get anything in terminal A from running the following

mosquitto_pub -t in_topic -m "hello world1"

Because your bridge is set up to only forward things on out_topic from the local broker to the remote (test.mosquitto.org)

topic out_topic out 0

Upvotes: 1

Related Questions