# Critical ! Message is discarded when MQTT out node is in Connection state

**URL:** <https://discourse.nodered.org/t/critical-message-is-discarded-when-mqtt-out-node-is-in-connection-state/78539>\
**Category:** General\
**Created:** [19 May 2023 11:09 UTC](https://discourse.nodered.org/t/critical-message-is-discarded-when-mqtt-out-node-is-in-connection-state/78539 "2023-05-19T11:09:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/josh/32/62208_2.png) [@Josh](https://discourse.nodered.org/u/Josh)\
**Post date:** [19 May 2023 11:09 UTC](https://discourse.nodered.org/t/critical-message-is-discarded-when-mqtt-out-node-is-in-connection-state/78539/1 "2023-05-19T11:09:28Z")

</div>

I have a flow like this.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/2/82c9873e2400b1c7d56278a6e03fdb93aaf49b31.png)

Lets take a case.  
When I press the inject button and MQTT out node is in connecting state where does my timestamp message go?

I have a similar case where I should not loose any data.

- In this case how can I do?
- What is the best practice?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [19 May 2023 11:21 UTC](https://discourse.nodered.org/t/critical-message-is-discarded-when-mqtt-out-node-is-in-connection-state/78539/2 "2023-05-19T11:21:00Z")

</div>

Send the message using the [retain flag](https://duckduckgo.com/?q=using+mqtt+retained&ia=web), then when any device reconnects the last retained topic will be resent. You can also set [QOS](https://assetwolf.com/learn/mqtt-qos-understanding-quality-of-service) to 2 to get a handshake

---

<div class="post-metadata">

**Author:** ![Josh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/josh/32/62208_2.png) [@Josh](https://discourse.nodered.org/u/Josh)\
**Post date:** [19 May 2023 11:30 UTC](https://discourse.nodered.org/t/critical-message-is-discarded-when-mqtt-out-node-is-in-connection-state/78539/3 "2023-05-19T11:30:29Z")

</div>

Hi @E1cid Thanks for the prompt reply. My main query is that what happens when the MQTT OUT node is in "connecting state" and a data is sent to the node? Where does that data go? Does the data gets stored somewhere?

If at all the data is not sent. The mqtt node is still in connecting state and doesnt even throw up an error. Now how can I catch that error?  
P.S: Error being that the data is not being able to send.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [19 May 2023 11:35 UTC](https://discourse.nodered.org/t/critical-message-is-discarded-when-mqtt-out-node-is-in-connection-state/78539/4 "2023-05-19T11:35:29Z")

</div>

You could queue the messages with the delay node and rate limit, set to a high rate delay. Then use a status node to start flushing the messages, once connected and queue again if disconnected. read the help text on these nodes to see how this would work, there are also many examples of this on the forum, This [post](https://discourse.nodered.org/t/announce-improved-guaranteed-delivery-flow/39877) may help to

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [19 May 2023 13:01 UTC](https://discourse.nodered.org/t/critical-message-is-discarded-when-mqtt-out-node-is-in-connection-state/78539/5 "2023-05-19T13:01:29Z")

</div>

What do you have for the settings of the mqtt-out node?  
What do you have for the settings of the mqtt-in node?

It's interesting that the out node is in a 'connecting' state while the in node is connected.

---

<div class="post-metadata">

**Author:** ![Josh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/josh/32/62208_2.png) [@Josh](https://discourse.nodered.org/u/Josh)\
**Post date:** [19 May 2023 13:21 UTC](https://discourse.nodered.org/t/critical-message-is-discarded-when-mqtt-out-node-is-in-connection-state/78539/6 "2023-05-19T13:21:14Z")

</div>

Hi @zenofmud Thanks for the comment. Actually I purposefully simulated this condition and wanted community advice/solution for it. Yes I have misconfigured the settings in MQTT OUT node for it to behave so as in simulating a real world scenario.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 July 2023 13:21 UTC](https://discourse.nodered.org/t/critical-message-is-discarded-when-mqtt-out-node-is-in-connection-state/78539/7 "2023-07-18T13:21:40Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
