RSMB 不使用 MQTT-SN 确认发布消息
RSMB does not acknowledge publish message with MQTT-SN
我是 运行 Really Small Message Broker (RSMB) 1.3.0.2,支持 MQTT-SN。我有一个 Arduino 客户端通过 MQTT-SN 协议与其通信。
Arduino 是一个睡眠客户端 - 电池供电设备。
它是这样工作的:
- 启动后,连接到代理
- 对于每个传感器值,它都会注册主题并在 QOS 1 中发布第一个测量值(在此示例中有 3 个传感器值)
2.1 每个注册和发布消息都被代理确认
- 与持续时间的代理断开连接 - 表示它即将休眠
- 唤醒后,它会再次使用干净的会话 0(或错误)重新连接
- 在 QOS 1 中发布一个传感器值
- 等待来自代理的发布确认 - 这是问题,它没有出现。
问题是第 5 步中发送的消息没有被代理确认。 Arduino 尝试重新发送该消息几次,但它放弃了。
我的理解是,在与 cleansession 0 重新连接后,所有以前的订阅都是有效的,并且 topicID 到主题名称的映射也是有效的。
这是包含我的评论的 RSBM 日志:
Client connects
20150227 152211.587 132 127.0.0.1:55701 <- MQTT-S CONNECT cleansession: 0
20150227 152211.587 1998536376 127.0.0.1:55701 XinoRf_1 -> MQTT-S CONNACK returncode 0 (0)
20150227 152211.588 CWNAN0000I Client connected to udp port 1885 from XinoRf_1 (127.0.0.1:55701)
Here start 1st topic registration and acknowledgment - its id is 1
20150227 152211.678 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S REGISTER msgid: 1 topicid: 0 topicname: net/mf/ha/
20150227 152211.678 132 127.0.0.1:55701 XinoRf_1 -> MQTT-S REGACK msgid: 1 topicid: 1 returncode: 0 (0)
Here starts send and acknowledge of a 1st message in topic 1
20150227 152211.753 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 2 qos: 1 retained: 0
20150227 152211.753 1998536376 127.0.0.1:55701 XinoRf_1 -> MQTT-S PUBACK msgid: 2 (0)
Here start 2nd topic registration and acknowledgment - its id is 2
20150227 152211.753 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S REGISTER msgid: 3 topicid: 0 topicname: net/mf/ha/
20150227 152211.846 132 127.0.0.1:55701 XinoRf_1 -> MQTT-S REGACK msgid: 3 topicid: 2 returncode: 0 (0)
Here starts send and acknowledge of a 1st message in topic 2
20150227 152211.921 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 4 qos: 1 retained: 0
20150227 152211.921 1998536376 127.0.0.1:55701 XinoRf_1 -> MQTT-S PUBACK msgid: 4 (0)
Here start 3rd topic registration and acknowledgment - its id is 3
20150227 152212.005 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S REGISTER msgid: 5 topicid: 0 topicname: net/mf/ha/
20150227 152212.005 132 127.0.0.1:55701 XinoRf_1 -> MQTT-S REGACK msgid: 5 topicid: 3 returncode: 0 (0)
Here starts send and acknowledge of a 1st message in topic 3
20150227 152212.080 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 6 qos: 1 retained: 0
20150227 152212.080 1998536376 127.0.0.1:55701 XinoRf_1 -> MQTT-S PUBACK msgid: 6 (0)
Here Arduino sends disconnect request with duration 4000 (it does not matter what value is sent here, behaviour is same)
20150227 152212.080 1998536376 127.0.0.1:55701 XinoRf_1 <- MQTT-S DISCONNECT duration: 4000
20150227 152212.461 CWNAN0038I Disconnection request received from client XinoRf_1
20150227 152212.461 132 127.0.0.1:55701 XinoRf_1 -> MQTT-S DISCONNECT duration: 0 (0)
At this point Arduino sleeps appprox. 4 seconds
Arduino reconnects with clean session 0 - I believe all previous registrations should be kept by the broker
20150227 152217.519 132 127.0.0.1:55701 <- MQTT-S CONNECT cleansession: 0
20150227 152217.519 1998536376 127.0.0.1:55701 XinoRf_1 -> MQTT-S CONNACK returncode 0 (0)
20150227 152217.519 CWNAN0000I Client connected to udp port 1885 from XinoRf_1 (127.0.0.1:55701)
At this point Arduino is connecte
Here starts send a 2nd message in topic 1 - message never gets acknowledged by the broker.
20150227 152217.603 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 7 qos: 1 retained: 0
Following messages are resent by the client
20150227 152232.595 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 7 qos: 1 retained: 0
20150227 152247.575 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 7 qos: 1 retained: 0
20150227 152301.577 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 7 qos: 1 retained: 0
20150227 152317.536 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 7 qos: 1 retained: 0
20150227 152332.516 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 7 qos: 1 retained: 0
随后我发现 eclipse.org(现在正在维护 RSMB)上报告的错误很少是导致此行为的原因:
- Bug 424704 - MQTT-SN broker forgets published topics
- Bug 430788 - When a client reconnects it don't receive queued messages
- Bug 430828 - If persistence is true on RSMB a MQTT-SN client don't receive messages published before its connection
迈克尔
固定 RSMB 版本可在
上使用
- Github: https://github.com/MichalFoksa/rsmb
- 或者作为 Eclipse Bugzilla 中的补丁:https://bugs.eclipse.org/bugs/show_bug.cgi?id=424704
我是 运行 Really Small Message Broker (RSMB) 1.3.0.2,支持 MQTT-SN。我有一个 Arduino 客户端通过 MQTT-SN 协议与其通信。
Arduino 是一个睡眠客户端 - 电池供电设备。 它是这样工作的:
- 启动后,连接到代理
- 对于每个传感器值,它都会注册主题并在 QOS 1 中发布第一个测量值(在此示例中有 3 个传感器值) 2.1 每个注册和发布消息都被代理确认
- 与持续时间的代理断开连接 - 表示它即将休眠
- 唤醒后,它会再次使用干净的会话 0(或错误)重新连接
- 在 QOS 1 中发布一个传感器值
- 等待来自代理的发布确认 - 这是问题,它没有出现。
问题是第 5 步中发送的消息没有被代理确认。 Arduino 尝试重新发送该消息几次,但它放弃了。
我的理解是,在与 cleansession 0 重新连接后,所有以前的订阅都是有效的,并且 topicID 到主题名称的映射也是有效的。
这是包含我的评论的 RSBM 日志:
Client connects
20150227 152211.587 132 127.0.0.1:55701 <- MQTT-S CONNECT cleansession: 0
20150227 152211.587 1998536376 127.0.0.1:55701 XinoRf_1 -> MQTT-S CONNACK returncode 0 (0)
20150227 152211.588 CWNAN0000I Client connected to udp port 1885 from XinoRf_1 (127.0.0.1:55701)
Here start 1st topic registration and acknowledgment - its id is 1
20150227 152211.678 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S REGISTER msgid: 1 topicid: 0 topicname: net/mf/ha/
20150227 152211.678 132 127.0.0.1:55701 XinoRf_1 -> MQTT-S REGACK msgid: 1 topicid: 1 returncode: 0 (0)
Here starts send and acknowledge of a 1st message in topic 1
20150227 152211.753 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 2 qos: 1 retained: 0
20150227 152211.753 1998536376 127.0.0.1:55701 XinoRf_1 -> MQTT-S PUBACK msgid: 2 (0)
Here start 2nd topic registration and acknowledgment - its id is 2
20150227 152211.753 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S REGISTER msgid: 3 topicid: 0 topicname: net/mf/ha/
20150227 152211.846 132 127.0.0.1:55701 XinoRf_1 -> MQTT-S REGACK msgid: 3 topicid: 2 returncode: 0 (0)
Here starts send and acknowledge of a 1st message in topic 2
20150227 152211.921 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 4 qos: 1 retained: 0
20150227 152211.921 1998536376 127.0.0.1:55701 XinoRf_1 -> MQTT-S PUBACK msgid: 4 (0)
Here start 3rd topic registration and acknowledgment - its id is 3
20150227 152212.005 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S REGISTER msgid: 5 topicid: 0 topicname: net/mf/ha/
20150227 152212.005 132 127.0.0.1:55701 XinoRf_1 -> MQTT-S REGACK msgid: 5 topicid: 3 returncode: 0 (0)
Here starts send and acknowledge of a 1st message in topic 3
20150227 152212.080 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 6 qos: 1 retained: 0
20150227 152212.080 1998536376 127.0.0.1:55701 XinoRf_1 -> MQTT-S PUBACK msgid: 6 (0)
Here Arduino sends disconnect request with duration 4000 (it does not matter what value is sent here, behaviour is same)
20150227 152212.080 1998536376 127.0.0.1:55701 XinoRf_1 <- MQTT-S DISCONNECT duration: 4000
20150227 152212.461 CWNAN0038I Disconnection request received from client XinoRf_1
20150227 152212.461 132 127.0.0.1:55701 XinoRf_1 -> MQTT-S DISCONNECT duration: 0 (0)
At this point Arduino sleeps appprox. 4 seconds
Arduino reconnects with clean session 0 - I believe all previous registrations should be kept by the broker
20150227 152217.519 132 127.0.0.1:55701 <- MQTT-S CONNECT cleansession: 0
20150227 152217.519 1998536376 127.0.0.1:55701 XinoRf_1 -> MQTT-S CONNACK returncode 0 (0)
20150227 152217.519 CWNAN0000I Client connected to udp port 1885 from XinoRf_1 (127.0.0.1:55701)
At this point Arduino is connecte
Here starts send a 2nd message in topic 1 - message never gets acknowledged by the broker.
20150227 152217.603 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 7 qos: 1 retained: 0
Following messages are resent by the client
20150227 152232.595 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 7 qos: 1 retained: 0
20150227 152247.575 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 7 qos: 1 retained: 0
20150227 152301.577 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 7 qos: 1 retained: 0
20150227 152317.536 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 7 qos: 1 retained: 0
20150227 152332.516 132 127.0.0.1:55701 XinoRf_1 <- MQTT-S PUBLISH msgid: 7 qos: 1 retained: 0
随后我发现 eclipse.org(现在正在维护 RSMB)上报告的错误很少是导致此行为的原因:
- Bug 424704 - MQTT-SN broker forgets published topics
- Bug 430788 - When a client reconnects it don't receive queued messages
- Bug 430828 - If persistence is true on RSMB a MQTT-SN client don't receive messages published before its connection
迈克尔
固定 RSMB 版本可在
上使用- Github: https://github.com/MichalFoksa/rsmb
- 或者作为 Eclipse Bugzilla 中的补丁:https://bugs.eclipse.org/bugs/show_bug.cgi?id=424704