RSMB不会使用MQTT-SN确认发布消息

时间:2015-02-27 16:25:54

标签: arduino mqtt mosquitto

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

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

  1. 启动后,连接到经纪人
  2. 对于每个传感器值,它注册主题并在QOS 1中发布第一个测量值(在此示例中有3个传感器值) 2.1每个注册和发布消息都由经纪人承认
  3. 与持续时间的经纪人断开连接 - 表明它正在睡觉
  4. 唤醒后,它再次与干净的会话0重新连接(或错误)
  5. 在QOS 1中发布一个传感器值
  6. 等待来自经纪人的发布确认 - 这是问题,它没有来。
  7. 问题是代理不会确认步骤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很少,这是造成这种行为的原因:

    1. Bug 424704 - MQTT-SN broker forgets published topics
    2. Bug 430788 - When a client reconnects it don't receive queued messages
    3. Bug 430828 - If persistence is true on RSMB a MQTT-SN client don't receive messages published before its connection
    4. 米甲

1 个答案:

答案 0 :(得分:1)

上有固定的RSMB版本
  1. Github:https://github.com/MichalFoksa/rsmb
  2. 或者作为Ec​​lipse Bugzilla中的补丁:https://bugs.eclipse.org/bugs/show_bug.cgi?id=424704