micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

Umqtt.simple re-subscribe issue

Open samf48 opened this issue 6 years ago • 2 comments

Hello I have a device in which I am using this library to subscribe and publish. The publish works well an the subscribe works IF my device is actively on and connected. What I mean by this is that if I am subscribed to a topic and I publish to said topic, then all is well. However my device actually powers down in a cyclic fashion and only powers up when it wants to publish. So with that said, how can I get messages from my subscribed topic once my device powers back up and then "re-subscribes" ? I'm pretty sure someone is doing this already but I haven't found a clear way to do it. Or is this something that is dependent on the server side?

samf48 avatar May 14 '20 22:05 samf48

hi samf48, I wold just publish a message to be informed about the new start. What do you think?

HerbV avatar Jun 08 '20 19:06 HerbV

To get the last message on a subscribe, the "retained message" feature in MQTT must be used. See for example https://www.hivemq.com/blog/mqtt-essentials-part-8-retained-messages/ for an explainer. The client that publishes the message must set the retain flag.

jonnor avatar Aug 25 '24 12:08 jonnor