Paho MQTT client connection reliability (reconnect on disconnection)

℡╲_俬逩灬. 提交于 2019-12-03 07:47:19
  1. Set a client_id so it's the same across reconnects
  2. Set the clean_session=false connection option
  3. Subscribe at QOS greater than 0

These options will help ensure that any messages published while disconnected will be delivered once the connection is restored.

You can set the client_id and clean_session flag in the constructor

client = mqtt.Client(client_id="foo123", clean_session=False)

And set the QOS of the subscription after the topic

client.subscribe(topic, qos=1)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!