由于系统认可,Mosquitto订阅了来自mosquitto_pub的错过消息

时间:2018-04-20 10:16:41

标签: ubuntu mqtt mosquitto

我有2个代理agentAagentB,A正试图发布到B的广播频道。

在主题mosquitto_sub上运行agentB/broadcast时,我不断收到以下返回消息:

Client agentB sending CONNECT
Client agentB received CONNACK
Client agentB sending SUBSCRIBE (Mid: 1, Topic: dispatcher/broadcast, QoS: 2)
Client agentB received SUBACK
Subscribed (mid: 1): 2
Client agentB sending CONNECT
Client agentB received CONNACK
Client agentB sending SUBSCRIBE (Mid: 2, Topic: dispatcher/broadcast, QoS: 2)
Client agentB received SUBACK
Subscribed (mid: 2): 2
Client agentB sending CONNECT
Client agentB received CONNACK
Client agentB sending SUBSCRIBE (Mid: 3, Topic: dispatcher/broadcast, QoS: 2)
Client agentB received SUBACK
Subscribed (mid: 3): 2

这有时会使mosquitto_pub“未命中”,这意味着如果我按下系统推送连接消息的窗口,我的消息就不会被发布。

任何可以解决此问题的解决方案? 谢谢。

编辑:订阅的命令

mosquitto_sub -h localhost -p 8883 -v -t agentB/broadcast --cafile /etc/mosquitto/ca_certificates/testing.crt -i agentA -d --cert /usr/share/agentA/config.crt --key /usr/share/agentA/config.key

1 个答案:

答案 0 :(得分:0)

我找到了根本原因。根本原因是自从系统启动以来,agentA和agentB已经在后台运行。因此,当我手动执行mosquitto_sub时,它将继续创建与该agentB/broadcast主题的新连接并关闭旧连接。如果您将mqtt作为服务,可以从journalctl -fu mqtt检查。