【问题标题】:Durable MQTT session on watson-iot (pythonwatson-iot 上的持久 MQTT 会话(python
【发布时间】:2017-11-22 09:51:10
【问题描述】:

如果订阅者应用程序断开连接一段时间(例如崩溃),是否可以获得所有丢失的事件?

我希望将 clean-session 设置为 true 以获得这种行为,但它不起作用。这是我的代码:

import ibmiotf.application

options = {
    "org": "org",
    "id": "some-id",
    "auth-method": "apikey",
    "auth-key": "key",
    "auth-token": "token",
    "clean-session": False
}
client = ibmiotf.application.Client(options)
client.connect()
client.deviceEventCallback = eventCallback
client.subscribeToDeviceEvents(deviceType="deviceType")

谢谢!

【问题讨论】:

    标签: python-3.x mqtt watson-iot


    【解决方案1】:

    您还需要使用 QoS1 或 QoS2 发布消息并设置

    client.subscribeToDeviceEvents(deviceType="deviceType",qos=1)

    基本上,你需要做的是:

    clean_session =假,

    发布和订阅 qos(服务质量)= 1

    这样,当订阅者重新连接时,将收到您发布的消息。

    可以在此处找到有关 watson-iot 消息传递的所有详细信息。 https://console.bluemix.net/docs/services/IoT/reference/mqtt/index.html#qos-levels

    【讨论】:

    • 这基本上是一个仅链接的答案。请对其进行编辑以包括包含更详细说明的基本信息
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-22
    • 1970-01-01
    • 2016-08-10
    • 1970-01-01
    • 1970-01-01
    • 2022-06-21
    相关资源
    最近更新 更多