MOSQUITO代理在收到PINGREQ后停止处理发布服务器和订阅服务器

2024-05-18 09:40:30 发布

您现在位置:Python中文网/ 问答频道 /正文

代理和客户端的连接和总体状态正常,直到两个客户端都发送了PINGREQ包,然后mosquitto代理停止从发布服务器接收其他信息

以下是日志:

1609145894: New connection from 127.0.0.1:47474 on port 1883.
1609145894: New client connected from 127.0.0.1:47474 as publisher (p5, c1, k5).
1609145894: No will message specified.
1609145894: Sending CONNACK to publisher (0, 0)
1609145894: New connection from 127.0.0.1:47476 on port 1883.
1609145894: New client connected from 127.0.0.1:47476 as subscriber (p5, c1, k5).
1609145894: No will message specified.
1609145894: Sending CONNACK to subscriber (0, 0)
1609145894: Received SUBSCRIBE from subscriber
1609145894:     /OS (QoS 2)
1609145894: subscriber 2 /OS
1609145894: Sending SUBACK to subscriber
1609145896: Received PUBLISH from publisher (d0, q2, r0, m20355, '/OS', ... (3 bytes))
1609145896: Sending PUBREC to publisher (m20355, rc0)
1609145898: Received PUBREL from publisher (Mid: 20355)
1609145898: Sending PUBLISH to subscriber (d0, q2, r0, m1, '/OS', ... (3 bytes))
1609145898: Sending PUBCOMP to publisher (m20355)
1609145898: Received PUBREC from subscriber (Mid: 20355)
1609145898: Warning: Received PUBREC from subscriber for an unknown packet identifier 20355.
1609145898: Sending PUBREL to subscriber (m20355)
1609145898: Received PUBCOMP from subscriber (Mid: 20355, RC:0)
1609145899: Received PINGREQ from publisher
1609145899: Sending PINGRESP to publisher
1609145899: Received PINGREQ from subscriber
1609145899: Sending PINGRESP to subscriber

然后代理只从客户端接收PINGREQ并将PINGRESP发送回

这就是我实现客户机的方式:https://pastebin.com/0iq6eRg8(3个线程:一个用于接收数据包,一个用于发送数据包,第三个用于在保持活动状态下保持连接-在最大时间为1.5*保持活动状态期间发送PINGREQ)
如果仅在其中一个客户端(发布服务器或订阅服务器)上启动keep alive线程,则似乎一切正常,不会再现这种情况


Tags: tofrom服务器客户端代理newospublisher