My aim is to 'forward' publications on my broker to other brokers such that publications on root/phone/random/# on my broker are forwarded to other brokers as root/bridge/random/#.
Here is the configuration file for "my" broker.
port 11884
persistence true
persistence_location /var/lib/mosquitto/
log_dest stdout
log_type debug
#
connection A-B-bridge
address localhost:11885
topic random/# out root/phone/ root/bridge/
clientid A-B-broker
cleansession false
#
connection A-C-bridge
address localhost:11886
topic random/# out root/phone/ root/bridge/
clientid A-C-broker
cleansession false
Once all the brokers have started, this is what I see on "my" broker.
1407855634: Bridge A-B-broker doing local SUBSCRIBE on topic root/bridge/random/#
1407855634: Bridge A-B-broker sending CONNECT
1407855634: Bridge A-C-broker doing local SUBSCRIBE on topic root/bridge/random/#
1407855634: Bridge A-C-broker sending CONNECT
1407855634: Received CONNACK on connection A-B-broker.
1407855634: Bridge A-B-broker sending UNSUBSCRIBE (Mid: 2, Topic: random/#)
1407855634: Received PUBACK from A-B-broker (Mid: 1)
1407855634: Received CONNACK on connection A-C-broker.
1407855634: Bridge A-C-broker sending UNSUBSCRIBE (Mid: 2, Topic: random/#)
1407855634: Received UNSUBACK from A-B-broker
1407855634: Received PUBACK from A-C-broker (Mid: 1)
1407855634: Received UNSUBACK from A-C-broker
Because I want to 'export' the publications, I used the direction as out in my configuration file. I was hoping to see a subscription for
root/phone/random/# so that it is published to the remote brokers (on 11885 and 11886 ports) with topic string
root/bridge/random/#. Why does the bridge do a
local SUBSCRIBE to
root/bridge/random/# ?
Why does the bridge do an
UNSUBSCRIBE ? This one is very confusing ! The topic string is
random/# as can be seen in debug messages of the remote brokers (on 11885 and 11886 ports).
Broker on 11885 port:
1407855634: Sending CONNACK to A-B-broker (0)
1407855634: Received PUBLISH from A-B-broker (d0, q1, r1, m1, '$SYS/broker/connection/A-B-broker/state', ... (1 bytes))
1407855634: Sending PUBACK to A-B-broker (Mid: 1)
1407855634: Received UNSUBSCRIBE from A-B-broker
1407855634: random/#
1407855694: Received PINGREQ from A-B-broker
1407855694: Sending PINGRESP to A-B-broker
Broker on 11886 port:
1407855634: Sending CONNACK to A-C-broker (0)
1407855634: Received PUBLISH from A-C-broker (d0, q1, r1, m1, '$SYS/broker/connection/A-C-broker/state', ... (1 bytes))
1407855634: Sending PUBACK to A-C-broker (Mid: 1)
1407855634: Received UNSUBSCRIBE from A-C-broker
1407855634: random/#
1407855694: Received PINGREQ from A-C-broker
1407855694: Sending PINGRESP to A-C-broker
I tried reversing the prefixes on my bridge configuration as shown below.
port 11884
persistence true
persistence_location /var/lib/mosquitto/
log_dest stdout
log_type debug
#
connection A-B-bridge
address localhost:11885
topic random/# out root/bridge/ root/phone/
clientid A-B-broker
cleansession false
#
connection A-C-bridge
address localhost:11886
topic random/# out root/bridge/ root/phone/
clientid A-C-broker
cleansession false
In this case, when I publish to "my" broker with topic string, root/phone/random/m, I see the following in "my" broker:
1407856926: Received PUBLISH from mosqpub/12390-random- (d0, q0, r0, m0, 'root/phone/random/m', ... (6 bytes))
1407856926: Sending PUBLISH to A-B-broker (d0, q0, r0, m0, 'random/m', ... (6 bytes))
1407856926: Sending PUBLISH to A-C-broker (d0, q0, r0, m0, 'random/m', ... (6 bytes))
As you can see, the topic prefix replacement is not happening. (The other brokers do show a corresponding Received PUBLISH).
Can you please help me in arriving at the right bridge configuration parameters ?