我有2个代理agentA
和agentB
,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
答案 0 :(得分:0)
我找到了根本原因。根本原因是自从系统启动以来,agentA和agentB已经在后台运行。因此,当我手动执行mosquitto_sub
时,它将继续创建与该agentB/broadcast
主题的新连接并关闭旧连接。如果您将mqtt作为服务,可以从journalctl -fu mqtt
检查。