How to prevent loopback publish when mosquitto bridged with RabbitMQ MQTT?
Internet of Things
IoT Frameworks
2 years ago
5
Star Rating
1
Rating
_x000D_
_x000D_
I have two mosquitto brokers installed on PC1 (mosquitto v1.4.8) and PC2 (RabbitMQ v3.6.2 with MQTT Adapter).
Bridging initiated at PC1 like below
sensor/room1/ <-> office/room1/
But I noticed there is always a duplicate message being published back whenever the bridge is active, means all my application (on PC1) which subscribes to the same topic will receives the same message twice. What setting I did wrong here?
PC1 mosquitto.conf
connection bridge-pc1-to-pc2
address pc2-address.com
topic room1/# both 2 sensor/ office/
bridge_protocol_version mqttv311
notifications true
cleansession true
try_private false
To test loopback issue, I had PC1 subscribed to topic sensor/#
mosquitto_sub -t sensor/# -v -d
Then at PC1 I publish a test message
mosquitto_pub -t sensor/room1/temperature -m '{"value":27.3, "timestamp":"2016-06-03 14:02:38"}'
Broker at cloud (PC2) received the message correctly (message received only once)
Client mosqsub/3121-Dennis-iMa sending CONNECT
Client mosqsub/3121-Dennis-iMa received CONNACK
Client mosqsub/3121-Dennis-iMa sending SUBSCRIBE (Mid: 1, Topic: office/#, QoS: 0)
Client mosqsub/3121-Dennis-iMa received SUBACK
Subscribed (mid: 1): 0
Client mosqsub/3121-Dennis-iMa received PUBLISH (d0, q0, r0, m0, 'office/room1/temperature', ... (14 bytes))
office/room1/temperature {"value":27.3, "timestamp":"2016-06-03 14:02:38"}
But PC1 received the same message twice! Below is the Pi's output
Received CONNACK
Received SUBACK
Subscribed (mid: 1): 0
Received PUBLISH (d0, q0, r0, m0, 'sensor/room1/temperature', ... (14 bytes))
sensor/room1/temperature {"value":27.3, "timestamp":"2016-06-03 14:02:38"}
Received PUBLISH (d0, q0, r0, m0, 'sensor/room1/temperature', ... (14 bytes))
sensor/room1/temperature {"value":27.3, "timestamp":"2016-06-03 14:02:38"}
Why there is loopback published message and how to solve this?
Update 3 Jun 2016
This is not the same question with this question, as it does not involve horizontal scaling (1-to-many brokers)
Posted on 16 Aug 2022, this text provides information on IoT Frameworks related to Internet of Things. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Take Quiz To Earn Credits!
Turn Your Knowledge into Earnings.