订阅上的MOSQUITO MQTT循环

订阅上的MOSQUITO MQTT循环,mqtt,mosquitto,Mqtt,Mosquitto,我正在使用mosquito作为我的代理服务器。我想建立一个基于网桥连接的代理集群 当我发布并订阅主题“presence”时,我收到了来自三个代理服务器的无数重复消息 我有三台服务器,例如: 10.80.1.1、10.80.1.2 我对每台服务器都有以下配置 on server 10.80.1.1, the config as the following: connection myconn address 10.80.1.2:1881 topic # both cleansession true

我正在使用mosquito作为我的代理服务器。我想建立一个基于网桥连接的代理集群

当我发布并订阅主题“presence”时,我收到了来自三个代理服务器的无数重复消息

我有三台服务器,例如: 10.80.1.1、10.80.1.2

我对每台服务器都有以下配置

on server 10.80.1.1, the config as the following:
connection myconn
address 10.80.1.2:1881
topic # both
cleansession true
try_private false
bridge_attempt_unsubscribe false
notifications false
allow_anonymous true
start_type automatic
clientid Bridge3

on server 10.80.1.2, the config as the following:
connection myconn
address 10.80.1.1:1883
topic # both
cleansession true
try_private false
bridge_attempt_unsubscribe false
notifications false
allow_anonymous true
start_type automatic
clientid Bridge2

谁能帮我解决这个问题。

有一点-我想你在这里输入配置时犯了一个错误:

address 10.80.1.1:1883,10.80.1.2:1883
多个地址的分隔符是“”,而不是“,”

问题是您在订阅中创建了一个循环

当Bridge3收到消息时,它将发布到Bridge2。Bridge2知道消息来自Bridge3,并且Bridge3是一个桥接器,因此尽管主题规则说它应该将消息发送回Bridge3,但事实并非如此。但它会将消息发送到Bridge1

现在我假设Bridge1最终连接到Bridge3而不是Bridge2。在这种情况下,Bridge1不会将消息返回到Bridge2,原因与上面相同,但它会将消息发送到Bridge3

Bridge3不知道这是与原始消息相同的消息,因此它发布到Bridge1,因此循环继续


原问题的答案在上面

最新答复:

你应该使用

try_private true
这允许网桥向远程主机指示它们是网桥,并且是在某些情况下避免循环的方法。

延迟到参与方:)

这是一个循环,如配置
主题#两者
中所示

从任何一台服务器上删除/注释掉所有网桥配置,并在两台服务器上重新启动mosquitcho

            on server 10.80.1.1, the config as the following:
            connection myconn
            address 10.80.1.2:1881
            topic # both
            cleansession true
            try_private false
            bridge_attempt_unsubscribe false
            notifications false
            allow_anonymous true
            start_type automatic
            clientid Bridge3

            on server 10.80.1.2, the config as the following:
            #connection myconn
            #address 10.80.1.1:1883
            #topic # both
            #cleansession true
            #try_private false
            #bridge_attempt_unsubscribe false
            #notifications false
            #allow_anonymous true
            #start_type automatic
            #clientid Bridge2

在添加try_private true之后,我仍然面临着删除的问题