# MQTT Caching in the event of a WAN failure

**URL:** https://discourse.nodered.org/t/mqtt-caching-in-the-event-of-a-wan-failure/21315
**Category:** General
**Created:** [5 February 2020 15:01 UTC](https://discourse.nodered.org/t/mqtt-caching-in-the-event-of-a-wan-failure/21315 "2020-02-05T15:01:10Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [5 February 2020 15:10 UTC](https://discourse.nodered.org/t/mqtt-caching-in-the-event-of-a-wan-failure/21315/2 "2020-02-05T15:10:51Z")

</div>

Your device should set a LWT. This will be issued when there is no update within a certain period by the broker. This will inform subscribers that a device go offline

> **[What is MQTT Last Will and Testament (LWT)? – MQTT Essentials: Part 9](https://www.hivemq.com/blog/mqtt-essentials-part-9-last-will-and-testament/)**
>
> Learn the basics of MQTT Last Will and Testament (LWT) & how it helps maintain system integrity in the event of unexpected client disconnections.

For a message queue you have to implement something yourself that take care of this during the mqtt node disconnected to your broker.

A function node pushing the data into an array on it’s own context as log it gets don’t get “connected” form a status node supervising the mqtt out could do the job (if setting up a sql sever as in the contrib note mentioned below is a little bit overkill). If it receives “connected” it could empty the array to the mqtt out node and pass all incoming messages.

Perhaps more reading here

> [@MQTT - Storing data when disconnected](https://discourse.nodered.org/t/mqtt-storing-data-when-disconnected/9306/14):
>
> Fair enough. It would be nice if someone with this need picked up the task of helping improve the core nodes rather than create another fork.

---

_[View the full topic](https://discourse.nodered.org/t/mqtt-caching-in-the-event-of-a-wan-failure/21315)._
