繁体   English   中英

mosquitto mqtt 代理不会向订阅者发送超过 20 个发布数据包

[英]mosquitto mqtt broker won't send more than 20 publish packets to subscriber

我目前正在使用 python 开发 MQTT 客户端,并且可以创建发布和订阅 Mosquitto 代理的客户端。

问题是,无论如何,mosquitto 代理最多只会向订阅者客户端发送 20 个 PUBLISH 数据包,即使它长时间保持连接也是如此。

如何配置 mosquitto 向订阅者客户端发送超过 20 个 PUBLISH 数据包?

蚊子日志:

1608918436: Received PUBLISH from publisher (d1, q1, r0, m1, '/OS', ... (3 bytes))
1608918436: Sending PUBLISH to subscriber (d0, q1, r0, m17, '/OS', ... (3 bytes))
1608918436: Sending PUBACK to publisher (m1, rc0)
1608918438: Received PUBLISH from publisher (d1, q1, r0, m1, '/OS', ... (3 bytes))
1608918438: Sending PUBLISH to subscriber (d0, q1, r0, m18, '/OS', ... (3 bytes))
1608918438: Sending PUBACK to publisher (m1, rc0)
1608918440: Received PUBLISH from publisher (d1, q1, r0, m1, '/OS', ... (3 bytes))
1608918440: Sending PUBLISH to subscriber (d0, q1, r0, m19, '/OS', ... (3 bytes))
1608918440: Sending PUBACK to publisher (m1, rc0)
1608918442: Received PUBLISH from publisher (d1, q1, r0, m1, '/OS', ... (3 bytes))
1608918442: Sending PUBLISH to subscriber (d0, q1, r0, m20, '/OS', ... (3 bytes))

此时,mosquitto 代理不会向订阅者发送更多数据包,但当订阅者客户端发送 PINGREQ 以保持与代理的连接时,PINGRESP 除外。

1608918442: Sending PUBACK to publisher (m1, rc0)
1608918442: Received PINGREQ from subscriber
1608918442: Sending PINGRESP to subscriber
1608918444: Received PUBLISH from publisher (d1, q1, r0, m1, '/OS', ... (3 bytes))
1608918444: Sending PUBACK to publisher (m1, rc0)
1608918446: Received PUBLISH from publisher (d1, q1, r0, m1, '/OS', ... (3 bytes))
1608918446: Sending PUBACK to publisher (m1, rc0)

如果确实需要,我很乐意为客户提供代码。

稍后编辑:也许值得一提
如果一个主题有更多订阅者,则这种行为是不可观察的,代理会发送数据包而不会在任何时候停止。

20 条消息听起来您正在达到最大的机上消息数(最大未确认消息数)

这些消息是 QOS 1,因此您的客户需要确认它们。

通过修改mosquitto.conf文件中的max_inflight_messages0解决了这个问题。

对于完全相同的情况,我有不同的解决方案:

在我的发布者中,我没有围绕发布消息编写“client.loop_start()”和“client.loop_stop()”。 添加这两行解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM