# Mqtt out node not able to generate a will message

**URL:** <https://discourse.nodered.org/t/mqtt-out-node-not-able-to-generate-a-will-message/418>\
**Category:** General\
**Created:** [26 May 2018 14:38 UTC](https://discourse.nodered.org/t/mqtt-out-node-not-able-to-generate-a-will-message/418 "2018-05-26T14:38:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gl007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gl007/32/95124_2.png) [@gl007](https://discourse.nodered.org/u/gl007)\
**Post date:** [26 May 2018 14:38 UTC](https://discourse.nodered.org/t/mqtt-out-node-not-able-to-generate-a-will-message/418/1 "2018-05-26T14:38:19Z")

</div>

Hello,

I am writing my question here, because I haven’t found anything on the forum that is similar to my problem.

I am trying to set a will message (QoS 1, retained) to an mqtt out node in my flow, but apparently the Broker is not being notified about it. To be specific, when I force a disconnection (by stopping node-red), if I watch the messages on the mqtt Broker (using a different machine as an mqtt client), I don’t see the will message. However if I connect to the same Broker with the use of MQTTBox (after having set the will topic and message on it), when I disconnect from the Broker, the will message (and topic) appears on it. Am I missing something or is this the normal behavior of the mqtt out node?

I hope my question is not a dumb one…

---

<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:** [26 May 2018 14:47 UTC](https://discourse.nodered.org/t/mqtt-out-node-not-able-to-generate-a-will-message/418/2 "2018-05-26T14:47:09Z")

</div>

could you provide your flow? (export it and paste it into a reply.

what version of NR, node?  
what machine/os?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [26 May 2018 14:56 UTC](https://discourse.nodered.org/t/mqtt-out-node-not-able-to-generate-a-will-message/418/3 "2018-05-26T14:56:01Z")

</div>

LWT only fires on an unexpected disconnect.

Within the latest version of Node-RED the MQTT node includes a “Message sent before disconnecting (close message)”

I’d try updating and see if it does what you want it to.

---

<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:** [26 May 2018 14:56 UTC](https://discourse.nodered.org/t/mqtt-out-node-not-able-to-generate-a-will-message/418/4 "2018-05-26T14:56:20Z")

</div>

Can you export the mqtt out node config (by selecting it, and click Ctrl-E) and paste it here please.

---

<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:** [26 May 2018 15:01 UTC](https://discourse.nodered.org/t/mqtt-out-node-not-able-to-generate-a-will-message/418/5 "2018-05-26T15:01:37Z")

</div>

Ignore me, @ukmoose is right, the LWT message is not sent on a normal shutdown. It would be if you unplugged the network for example, assuming there is a network between node red and the broker. That is how it is supposed to work according to the MQTT spec.

---

<div class="post-metadata">

**Author:** ![gl007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gl007/32/95124_2.png) [@gl007](https://discourse.nodered.org/u/gl007)\
**Post date:** [26 May 2018 15:08 UTC](https://discourse.nodered.org/t/mqtt-out-node-not-able-to-generate-a-will-message/418/6 "2018-05-26T15:08:39Z")

</div>

Thanks, I will look at it, including updating node-red.

I will also try it by just unplugging the machine from the network.

But anyway, the answer is that this is normal, expected behavior.
