Mqtt out node not able to generate a will message


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…

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

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

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.

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

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.

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.