# MQTT Nodes Connection Behaviour

**URL:** https://discourse.nodered.org/t/mqtt-nodes-connection-behaviour/45954
**Category:** General
**Created:** [20 May 2021 01:48 UTC](https://discourse.nodered.org/t/mqtt-nodes-connection-behaviour/45954 "2021-05-20T01:48:21Z")
**Posts on this page:** 1
**Showing post:** 20

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [27 May 2021 08:31 UTC](https://discourse.nodered.org/t/mqtt-nodes-connection-behaviour/45954/20 "2021-05-27T08:31:24Z")

</div>

> [@Siothrun](#):
>
> When writing values from the HMI to the PLC QoS 0 is required. If the internet connection is interrupted I don’t want a value/command being buffered and written to the PLC at a later date.

I suspect that using QoS 0 does not absolutely guarantee that the value will not be buffered in the mqtt driver and sent later. If it is essential that you do not use old data then I suggest adding a timestamp and check at the receiving end that it is not stale.

> [@Siothrun](#):
>
> When reading values from the PLC to display on the HMI QoS 2 is desired. The values read are time stamped and the history of what is happening is important. This is why the MQTT backfill is relevant to me.

I suggest writing the receiving end so that it ignores repeated messages. That will make your life much simpler. Then, if what you are after is guaranteeing that you do not lose any messages you can use something like this flow to send the data. The flow can even buffer the data over a node-red restart if that is required.

> [@Node-red-contrib-msg-queue - Only storing not forwarding w/ active connection](https://discourse.nodered.org/t/node-red-contrib-msg-queue-only-storing-not-forwarding-w-active-connection/44274/11):
>
> Give this a go. It uses the Guaranteed Delivery subflow from [here](https://flows.nodered.org/flow/05e6d61f14ef6af763ec4cfd1049ab61) with the logic to make it work with MQTT. Configure the MQTT node as required and send the messages to be sent in via the top left link node. It uses a Complete node attached to the MQTT node to know when the message has been sent successfully but there is no way to know when it has failed, so it uses a 5 second timeout to indicate that. When it fails it retries every 60 seconds. That can be configured in the subflow settings…

---

_[View the full topic](https://discourse.nodered.org/t/mqtt-nodes-connection-behaviour/45954)._
