Repeating messages in bridged environment

Asked by Byungchul Lee

Hello all,

I'm trying to setup two brokers with bridging support and I'm new to mosquitto server. I need some help.
The problem is I'm getting endlessly repeating messages from those brokers.

Configurations are as follows

- Server 1 (192.168.0.23:1883)

connection abvje_push
address 192.168.0.32:1883
topic hello both
clientid abvje.23
cleansession true
notifications true
keepalive_interval 60
start_type automatic
try_private true

- Server 2(192.168.0.32:1883)
connection abvje_push
address 192.168.0.23:1883
topic hello both
clientid abvje.32
cleansession true
notifications true
keepalive_interval 60
start_type automatic
try_private true

When I test the server, I used mosquitto_sub/pub to know how it works. When I try to send a message to a subscriber a few times, then same messages comes endlessly. This is not happen when only one server run. It happens only in bridging situation.

Logs - server 1
-------
mosquitto -c ./mosquitto.conf
1356322978: mosquitto version 1.1 (build date 2012-12-19 13:56:40+0000) starting
1356322978: Config loaded from ./mosquitto.conf.
1356322978: Opening ipv4 listen socket on port 1883.
1356322978: Opening ipv6 listen socket on port 1883.
1356322978: Warning: Address family not supported by protocol
1356322978: Connecting bridge abvje_push
1356322978: Error creating bridge.
1356322978: Warning: Unable to connect to bridge abvje_push.
1356322982: New connection from 192.168.0.32.
1356322982: New client connected from 192.168.0.32 as abvje.32.
1356323009: Connecting bridge abvje_push

Logs - server2
--------------
mosquitto -c ./mosquitto.conf
1356322978: mosquitto version 1.1 (build date 2012-12-19 13:56:40+0000) starting
1356322978: Config loaded from ./mosquitto.conf.
1356322978: Opening ipv4 listen socket on port 1883.
1356322978: Opening ipv6 listen socket on port 1883.
1356322978: Connecting bridge abvje_push
1356323005: New connection from 192.168.0.23.
1356323005: New client connected from 192.168.0.23 as abvje.23.

Now those two brokers seems connected.
- Subscribe
[root@localhost ~]# mosquitto_sub -h 192.168.0.23 -t hello

1356323217: New client connected from 192.168.0.32 as mosqsub/13286-localhost. (Log from Server 1, 192.168.0.23)

- Publish
[root@localhost log]# mosquitto_pub -t hello -h 192.168.0.23 -m 23

Then tons of messages are coming like this.
23
23
23
23
23
23
23
23
23
23
23
23
23
23
23
23
23

Any kind of help will be appreciated. Thanks in advance.

Question information

Language:
English Edit question
Status:
Solved
For:
mosquitto Edit question
Assignee:
No assignee Edit question
Solved by:
Roger Light
Solved:
Last query:
Last reply:
Revision history for this message
Best Roger Light (roger.light) said :
#1

Hi,

> address 192.168.0.32:1883
> topic hello both

> address 192.168.0.23:1883
> topic hello both

You have redundant bridging - you only need one of the bridges above,
or else just use "out" or "in" instead of "both" in both of the
bridges.

If you use "both" in a bridge then the bridge is intelligent enough to
detect which messages pass through it to prevent message loops, but
what you have above is two bridges that will appear as two clients so
this detection will not be possible.

Cheers,

Roger

Revision history for this message
Byungchul Lee (bc11-lee) said :
#2

Thanks Roger Light, that solved my question.

Revision history for this message
Byungchul Lee (bc11-lee) said :
#3

Thank you very much again.

I removed one bridge as you explained, and it works fine now.