Black Lives Matter - Action and Equality. ... Adafruit joins the Stop Hate for Profit campaign.

Offline Messages
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Offline Messages

by czuvich on Fri Oct 26, 2018 1:13 pm

Let's say I have device A that is using Adafruit IO MQTT over WiFi and is subscribed to a "feed_me" feed. Device B publishes a "feed_me" to the MQTT server; however, device A is disconnected from the MQTT server.

Does Adafruit IO hold onto these "missed" messages until device A connects? Or do these messages get completely missed? If it does hold onto the messages, is there some expiration?


Posts: 117
Joined: Fri May 20, 2016 6:53 pm

Re: Offline Messages

by abachman on Mon Oct 29, 2018 11:45 am

Hi czuvich,

The messages are saved, yes, but only as part of the normal data saving process that occurs while feed history is turned on (the default setting for all feeds). If feed history is turned on and you're on the free plan, IO holds all data for 30 days, but IO will not automatically resend data to MQTT clients.

If you only need the last known value for a feed--its current state--you can publish to the {username}/f/{feed_key}/get MQTT topic to force IO to resend the last value.

If you need to know all values that were sent since a particular time, you can use the HTTP API to request all recent data by setting the start_time parameter on your request to the created_at time of the last message you received. If, for example, your device received a message at 10:50am UTC on 2018-10-29, disconnected at some point after that, and then reconnected, you could send a properly authenticated HTTP GET request to{username}/feeds/{feed_key}/data?start_time='2018-10-29T10:50Z' and get all data that was published after the given time. If the request comes back empty, you know nothing was published, otherwise you can deal with the new data as needed.

- Adam B.

Posts: 352
Joined: Mon Feb 01, 2010 12:48 pm

Please be positive and constructive with your questions and comments.