# Node-red last will message

**URL:** <https://discourse.nodered.org/t/node-red-last-will-message/41214>\
**Category:** General\
**Created:** [18 February 2021 06:55 UTC](https://discourse.nodered.org/t/node-red-last-will-message/41214 "2021-02-18T06:55:15Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![tetrived](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@tetrived](https://discourse.nodered.org/u/tetrived)\
**Post date:** [18 February 2021 06:55 UTC](https://discourse.nodered.org/t/node-red-last-will-message/41214/1 "2021-02-18T06:55:15Z")

</div>

Hello All,

We are trying to simulate lastwill message scenario using node-red tool. We configured lastwill topic and message in the message tab. We are trying to close the node-red command window but it seems it is always graceful disconnect.

What is the way in node-red to simulate ungraceful disconnect ?

Thanks,  
Tejas

---

<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:** [18 February 2021 07:09 UTC](https://discourse.nodered.org/t/node-red-last-will-message/41214/2 "2021-02-18T07:09:48Z")

</div>

Unplug the network connection between node red server and the broker.  
Alternatively kill node red with the signal that forces an immediate stop. How you do this depends on your OS.

---

<div class="post-metadata">

**Author:** ![tetrived](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@tetrived](https://discourse.nodered.org/u/tetrived)\
**Post date:** [18 February 2021 07:22 UTC](https://discourse.nodered.org/t/node-red-last-will-message/41214/3 "2021-02-18T07:22:13Z")

</div>

I did the same kill process and node-red process in windows. but it doesn't seems to be working

---

<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:** [18 February 2021 13:59 UTC](https://discourse.nodered.org/t/node-red-last-will-message/41214/4 "2021-02-18T13:59:48Z")

</div>

I don't know how to kill a process in windows in such a way that it does not shut down gracefully, so can't help with that one.  
Did pulling the cable work?

---

<div class="post-metadata">

**Author:** ![aderici](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aderici/32/37279_2.png) [@aderici](https://discourse.nodered.org/u/aderici)\
**Post date:** [18 February 2021 20:55 UTC](https://discourse.nodered.org/t/node-red-last-will-message/41214/5 "2021-02-18T20:55:20Z")

</div>

First we should aggree that last will message wont be sent by node red but by the broker right? Because thats how last will messages work.

Is node red the client or the broker here?

If its the client and the broker is another mqtt server online then you can turn off the wifi on the node red server and wait for the timeout on the broker

---

<div class="post-metadata">

**Author:** ![tetrived](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@tetrived](https://discourse.nodered.org/u/tetrived)\
**Post date:** [19 February 2021 01:09 UTC](https://discourse.nodered.org/t/node-red-last-will-message/41214/6 "2021-02-19T01:09:10Z")

</div>

Yes, I mean broker here. So timeout means idle timeout of mqtt broker right?

---

<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:** [19 February 2021 07:08 UTC](https://discourse.nodered.org/t/node-red-last-will-message/41214/7 "2021-02-19T07:08:21Z")

</div>

> [@tetrived](#):
>
> I mean broker here. So timeout means idle timeout of mqtt broker right?

I am sorry, but that sentence means nothing to me.

---

<div class="post-metadata">

**Author:** ![aderici](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aderici/32/37279_2.png) [@aderici](https://discourse.nodered.org/u/aderici)\
**Post date:** [19 February 2021 10:28 UTC](https://discourse.nodered.org/t/node-red-last-will-message/41214/8 "2021-02-19T10:28:51Z")

</div>

Yes the right terminology is idle timeout i think.

So you need to disconnect the client not the broker here.

Broker will understand that the client has disconnected, and send the last will message that was shared by the client initially when the connection was opening.

Heres some additional reading about the topic :

[https://www.hivemq.com/blog/mqtt-essentials-part-9-last-will-and-testament/](https://www.hivemq.com/blog/mqtt-essentials-part-9-last-will-and-testament/)

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [19 February 2021 10:35 UTC](https://discourse.nodered.org/t/node-red-last-will-message/41214/9 "2021-02-19T10:35:26Z")

</div>

@tetrived as you've seen, simply stopping Node-RED allows the client to disconnect cleanly.

On Windows, I think you can use the `/f` option to `taskkill` in order to forceable end the process without letting it shutdown cleanly - [taskkill | Microsoft Docs](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill)

---

<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:** [20 April 2021 10:36 UTC](https://discourse.nodered.org/t/node-red-last-will-message/41214/10 "2021-04-20T10:36:00Z")

</div>

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