Detecting disconnection of MQTT out node

An image is better than thousand words.


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.

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

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.

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?

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

1 Like

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 :wink: that the MQTT nodes are not connected to that local Aedes broker, I cannot immediately think what else might be going on.

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

@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.

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.

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

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.

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

The fact, I'm working on that, 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 and start node red as a service (on boot or using node-red-start) then node-red-log should show the log.

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

if I try to run node-red-log, as you suggest (and it is also suggested here: Logging : Node-RED) I'll immediately have another instance of node trying to run and failing, as there is one already running

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

Pretty sure. Anyway, I will recheck next week.

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

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.```

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 ```)

``` 
   code goes here 
```

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

See this post for more details - How to share code or flow json

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.