# Detecting disconnection of MQTT out node

**URL:** <https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914>\
**Category:** General\
**Tags:** mqtt\
**Created:** [21 December 2023 12:27 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914 "2023-12-21T12:27:10Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![j2002](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@j2002](https://discourse.nodered.org/u/j2002)\
**Post date:** [21 December 2023 17:25 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/21 "2023-12-21T17:25:00Z")

</div>

An image is better than thousand words.

 ![PXL_20231221_171858583](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/284d54822c020f107518627bf61270879bcaa3dc.jpeg)  
As you can see, the Raspberry is not connected but MQTT out nodes show "connected" and, consequently, StoreNForward nodes don't do their job  
In the past I saw this working perfectly.

---

<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:** [21 December 2023 17:39 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/22 "2023-12-21T17:39:04Z")

</div>

How are you seeing that if Wi-Fi is disconnected?

---

<div class="post-metadata">

**Author:** ![j2002](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@j2002](https://discourse.nodered.org/u/j2002)\
**Post date:** [21 December 2023 17:49 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/23 "2023-12-21T17:49:22Z")

</div>

Because I turned it off. Look at the red crosses also. I tried to surf the web to confirm. The Raspberry has no internet connection for sure.

---

<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:** [21 December 2023 17:59 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/24 "2023-12-21T17:59:11Z")

</div>

But you said you access the pi via Wi-Fi, so how does the page update if the browser is not connected to the pi?

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [21 December 2023 22:49 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/25 "2023-12-21T22:49:23Z")

</div>

It looks like the browser is running on the Pi so no network needed.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [21 December 2023 22:54 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/26 "2023-12-21T22:54:42Z")

</div>

> [@Sean-McG](#):
>
> Also if you have LWT setup in NR, does the broker report a disconnection ?

Did you confirm this ?

Are you able to do a full deploy while the network is down, to see what the MQTT nodes show then ?

Other than triple checking 😉 that the MQTT nodes are not connected to that local Aedes broker, I cannot immediately think what else might be going on.

---

<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:** [22 December 2023 10:19 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/27 "2023-12-22T10:19:20Z")

</div>

> [@Sean-McG](#):
>
> It looks like the browser is running on the Pi

I think you may be right, though that confilicts (to some extent) with:

> [@j2002](#):
>
> I can connect to it by VNC or by a browser on my PC (via WIFI).

@j2002 if you do have a display on the pi then open a terminal there, run node-red-log so that it tails the log, and then disconnect the wifi.

---

<div class="post-metadata">

**Author:** ![j2002](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@j2002](https://discourse.nodered.org/u/j2002)\
**Post date:** [22 December 2023 12:36 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/28 "2023-12-22T12:36:32Z")

</div>

To do changes and developing, I usually connect via Wi-Fi. To show the problem and to take the last photo I thought it was better to open the browser on the RPI and show MQTT out nodes.  
Sorry I cannot respond yesterday as I'm new here and I've reached the limit of messages.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [22 December 2023 13:37 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/29 "2023-12-22T13:37:02Z")

</div>

So can you update us on any steps taken, regarding above suggestions ?

---

<div class="post-metadata">

**Author:** ![j2002](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@j2002](https://discourse.nodered.org/u/j2002)\
**Post date:** [22 December 2023 13:54 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/30 "2023-12-22T13:54:33Z")

</div>

Well, Aedes has been removed with no difference at all, I can deploy any modification completely offline (Mqtt out nodes are shown disconnected for a while. I must recheck when they are connected, after or before WiFi is turned on... Not sure at this moment).  
Thanks for the interest, I'll keep you updated.

---

<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:** [22 December 2023 13:58 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/31 "2023-12-22T13:58:20Z")

</div>

Don't forget to run `node-red-log` to see what that says when you disconnect the network.

---

<div class="post-metadata">

**Author:** ![j2002](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@j2002](https://discourse.nodered.org/u/j2002)\
**Post date:** [22 December 2023 14:18 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/32 "2023-12-22T14:18:07Z")

</div>

The fact, I'm working on that, as it seems not to be the same if node is running as a service.

---

<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:** [22 December 2023 14:28 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/33 "2023-12-22T14:28:20Z")

</div>

> [@j2002](#):
>
> as it seems not to be the same if node is running as a service.

What do you mean by that? Assuming that you installed using the[recommended install script](https://nodered.org/docs/getting-started/raspberrypi) and start node red as a service (on boot or using node-red-start) then node-red-log should show the log.

---

<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:** [22 December 2023 14:31 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/34 "2023-12-22T14:31:53Z")

</div>

Oh, do you mean that it works if node-red is run as a service?

---

<div class="post-metadata">

**Author:** ![j2002](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@j2002](https://discourse.nodered.org/u/j2002)\
**Post date:** [22 December 2023 15:47 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/35 "2023-12-22T15:47:54Z")

</div>

if I try to run node-red-log, as you suggest (and it is also suggested here: [Logging : Node-RED](https://nodered.org/docs/user-guide/runtime/logging)) I'll immediately have another instance of node trying to run and failing, as there is one already running

---

<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:** [22 December 2023 15:50 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/36 "2023-12-22T15:50:13Z")

</div>

Are you sure you are not running  
`node-red log`?  
`node-red-log` (no spaces) should not start anything.

---

<div class="post-metadata">

**Author:** ![j2002](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@j2002](https://discourse.nodered.org/u/j2002)\
**Post date:** [22 December 2023 15:52 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/37 "2023-12-22T15:52:49Z")

</div>

Pretty sure. Anyway, I will recheck next week.

---

<div class="post-metadata">

**Author:** ![j2002](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@j2002](https://discourse.nodered.org/u/j2002)\
**Post date:** [2 January 2024 09:04 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/38 "2024-01-02T09:04:08Z")

</div>

I am back again and trying your suggestions but I'm still stuck with the logs as node-red-log gives these results:

````Jan
Jan 02 09:32:09 raspberrypi Node-RED[360]: 2 Jan 09:32:09 - [info] Dashboard version 3.6.2 started at /ui
Jan 02 09:32:10 raspberrypi Node-RED[360]: 2 Jan 09:32:10 - [info] Settings file : /home/gesinne/.node-red/settings.js
Jan 02 09:32:10 raspberrypi Node-RED[360]: 2 Jan 09:32:10 - [info] Context store : 'default' [module=memory]
Jan 02 09:32:10 raspberrypi Node-RED[360]: 2 Jan 09:32:10 - [info] User directory : /home/gesinne/.node-red
Jan 02 09:32:10 raspberrypi Node-RED[360]: 2 Jan 09:32:10 - [warn] Projects disabled : editorTheme.projects.enabled=false
Jan 02 09:32:10 raspberrypi Node-RED[360]: 2 Jan 09:32:10 - [info] Flows file : /home/gesinne/.node-red/flows.json
Jan 02 09:32:11 raspberrypi Node-RED[360]: 2 Jan 09:32:11 - [error] Unable to listen on http://127.0.0.1:1880/
Jan 02 09:32:11 raspberrypi Node-RED[360]: 2 Jan 09:32:11 - [error] Error: port in use
Jan 02 09:32:11 raspberrypi systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE
Jan 02 09:32:11 raspberrypi systemd[1]: nodered.service: Failed with result 'exit-code'.
Jan 02 09:32:11 raspberrypi systemd[1]: nodered.service: Consumed 8.984s CPU time.
Jan 02 09:32:46 raspberrypi systemd[1]: nodered.service: Scheduled restart job, restart counter is at 1.
Jan 02 09:32:46 raspberrypi systemd[1]: Stopped Node-RED graphical event wiring tool.
Jan 02 09:32:46 raspberrypi systemd[1]: nodered.service: Consumed 8.984s CPU time.
Jan 02 09:32:46 raspberrypi systemd[1]: Started Node-RED graphical event wiring tool.
Jan 02 09:32:48 raspberrypi Node-RED[1285]: 2 Jan 09:32:48 - [info]
Jan 02 09:32:48 raspberrypi Node-RED[1285]: Welcome to Node-RED
Jan 02 09:32:48 raspberrypi Node-RED[1285]: ===================
Jan 02 09:32:48 raspberrypi Node-RED[1285]: 2 Jan 09:32:48 - [info] Node-RED version: v3.1.3
Jan 02 09:32:48 raspberrypi Node-RED[1285]: 2 Jan 09:32:48 - [info] Node.js version: v18.19.0
Jan 02 09:32:48 raspberrypi Node-RED[1285]: 2 Jan 09:32:48 - [info] Linux 6.1.21-v8+ arm LE
Jan 02 09:32:49 raspberrypi Node-RED[1285]: 2 Jan 09:32:49 - [info] Loading palette nodes
Jan 02 09:32:51 raspberrypi Node-RED[1285]: 2 Jan 09:32:51 - [info] Dashboard version 3.6.2 started at /ui
Jan 02 09:32:52 raspberrypi Node-RED[1285]: 2 Jan 09:32:52 - [info] Settings file : /home/gesinne/.node-red/settings.js
Jan 02 09:32:52 raspberrypi Node-RED[1285]: 2 Jan 09:32:52 - [info] Context store : 'default' [module=memory]
Jan 02 09:32:52 raspberrypi Node-RED[1285]: 2 Jan 09:32:52 - [info] User directory : /home/gesinne/.node-red
Jan 02 09:32:52 raspberrypi Node-RED[1285]: 2 Jan 09:32:52 - [warn] Projects disabled : editorTheme.projects.enabled=false
Jan 02 09:32:52 raspberrypi Node-RED[1285]: 2 Jan 09:32:52 - [info] Flows file : /home/gesinne/.node-red/flows.json
Jan 02 09:32:52 raspberrypi Node-RED[1285]: 2 Jan 09:32:52 - [error] Unable to listen on http://127.0.0.1:1880/
Jan 02 09:32:52 raspberrypi Node-RED[1285]: 2 Jan 09:32:52 - [error] Error: port in use
Jan 02 09:32:52 raspberrypi systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE
Jan 02 09:32:52 raspberrypi systemd[1]: nodered.service: Failed with result 'exit-code'.
Jan 02 09:32:52 raspberrypi systemd[1]: nodered.service: Consumed 7.071s CPU time.
Jan 02 09:33:12 raspberrypi systemd[1]: nodered.service: Scheduled restart job, restart counter is at 2.
Jan 02 09:33:12 raspberrypi systemd[1]: Stopped Node-RED graphical event wiring tool.
Jan 02 09:33:12 raspberrypi systemd[1]: nodered.service: Consumed 7.071s CPU time.
Jan 02 09:33:12 raspberrypi systemd[1]: Started Node-RED graphical event wiring tool.
Jan 02 09:33:14 raspberrypi Node-RED[1351]: 2 Jan 09:33:14 - [info]
Jan 02 09:33:14 raspberrypi Node-RED[1351]: Welcome to Node-RED
Jan 02 09:33:14 raspberrypi Node-RED[1351]: ===================
Jan 02 09:33:14 raspberrypi Node-RED[1351]: 2 Jan 09:33:14 - [info] Node-RED version: v3.1.3
Jan 02 09:33:14 raspberrypi Node-RED[1351]: 2 Jan 09:33:14 - [info] Node.js version: v18.19.0
Jan 02 09:33:14 raspberrypi Node-RED[1351]: 2 Jan 09:33:14 - [info] Linux 6.1.21-v8+ arm LE
Jan 02 09:33:16 raspberrypi Node-RED[1351]: 2 Jan 09:33:16 - [info] Loading palette nodes
Jan 02 09:33:18 raspberrypi Node-RED[1351]: 2 Jan 09:33:18 - [info] Dashboard version 3.6.2 started at /ui
Jan 02 09:33:19 raspberrypi Node-RED[1351]: 2 Jan 09:33:19 - [info] Settings file : /home/gesinne/.node-red/settings.js
Jan 02 09:33:19 raspberrypi Node-RED[1351]: 2 Jan 09:33:19 - [info] Context store : 'default' [module=memory]
Jan 02 09:33:19 raspberrypi Node-RED[1351]: 2 Jan 09:33:19 - [info] User directory : /home/gesinne/.node-red
Jan 02 09:33:19 raspberrypi Node-RED[1351]: 2 Jan 09:33:19 - [warn] Projects disabled : editorTheme.projects.enabled=false
Jan 02 09:33:19 raspberrypi Node-RED[1351]: 2 Jan 09:33:19 - [info] Flows file : /home/gesinne/.node-red/flows.json
Jan 02 09:33:19 raspberrypi Node-RED[1351]: 2 Jan 09:33:19 - [error] Unable to listen on local:1880/
Jan 02 09:33:19 raspberrypi Node-RED[1351]: 2 Jan 09:33:19 - [error] Error: port in use
Jan 02 09:33:19 raspberrypi systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE
Jan 02 09:33:19 raspberrypi systemd[1]: nodered.service: Failed with result 'exit-code'.
Jan 02 09:33:19 raspberrypi systemd[1]: nodered.service: Consumed 7.374s CPU time.
Jan 02 09:33:39 raspberrypi systemd[1]: nodered.service: Scheduled restart job, restart counter is at 3.```
````

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [2 January 2024 09:21 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/39 "2024-01-02T09:21:01Z")

</div>

> [@j2002](#):
>
> Unable to listen on [http://127.0.0.1:1880/](http://127.0.0.1:1880/)  
> Jan 02 09:32:52 raspberrypi Node-RED[1285]: 2 Jan 09:32:52 - [error] Error: port in use

Node-red is already running.

Close all instances then start the services.

If you are unsure how, the quickest resolution is to reboot the device (to kill running node-red) and let the service autostart.

* * *

Ps, please post logs and code in a code block

In order to make code/logs readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

**Author:** ![j2002](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@j2002](https://discourse.nodered.org/u/j2002)\
**Post date:** [2 January 2024 09:56 UTC](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914/40 "2024-01-02T09:56:34Z")

</div>

Thank you for the warning. It took me a while but I think it is corrected.  
Of course node-red is already running. And it must be so (it is programmed to restart at any failure) But I am unable to see the log of the current instance.

[Previous page](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914.md?page=1)

[Next page](https://discourse.nodered.org/t/detecting-disconnection-of-mqtt-out-node/83914.md?page=3)
