2

我正在运行支持 MQTT-SN 的真正小型消息代理 (RSMB) 1.3.0.2。我有一个 Arduino 客户端通过 MQTT-SN 协议与之交谈。

Arduino 是一个睡眠客户端 - 电池供电的设备。下面是它的工作原理:

  1. 启动后,连接到代理
  2. 对于每个传感器值,它注册主题并在 QOS 1 中发布第一个测量值(在此示例中,有 3 个传感器值) 2.1 每个注册和发布消息都由代理确认
  3. 与经纪人断开连接,持续时间 - 表明它只是要睡觉
  4. 唤醒后,它再次使用干净的会话 0(或错误)重新连接
  5. 在 QOS 1 中发布一个传感器值
  6. 等待来自经纪人的发布确认 - 这是问题,它没有出现。

问题是在步骤 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)上报告的错误很少,这是导致这种行为的原因:

  1. 错误 424704 - MQTT-SN 代理忘记发布的主题
  2. 错误 430788 - 当客户端重新连接时,它不会收到排队的消息
  3. 错误 430828 - 如果 RSMB 上的持久性为真,则 MQTT-SN 客户端不会接收在其连接之前发布的消息

迈克尔

4

1 回答 1

1

固定 RSMB 版本可在

  1. Github:https ://github.com/MichalFoksa/rsmb
  2. 或者作为 Eclipse Bugzilla 中的补丁:https ://bugs.eclipse.org/bugs/show_bug.cgi?id=424704
于 2015-03-09T21:47:31.767 回答