Node-Red restarting on Uncaught Exception

During the night, I see that randomly NR restarts. These are the log lines:

2024-01-09T02:56:47.312255+01:00 PI4bOpenVPN Node-RED[29652]: 9 Jan 02:56:47 - [red] Uncaught Exception:
2024-01-09T02:56:47.313265+01:00 PI4bOpenVPN Node-RED[29652]: 9 Jan 02:56:47 - [error] Error: connect ECONNREFUSED 18.203.57.224:443
2024-01-09T02:56:47.313572+01:00 PI4bOpenVPN Node-RED[29652]:     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)
2024-01-09T02:56:47.390845+01:00 PI4bOpenVPN systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE

The IP is on amazonaws.

How can I proceed troubleshooting this or - at least - catch the error?

Can you post the node-red startup log please, the one starting with the Welcome to node red message, and also the log leading up to the crash.

Also what node are you using to access amazonaws?

@Colin These are the log lines leading up to the crash and the subsequent restart of NR. I don0t know which palette is using amazonaws, maybe Alexa?

2024-01-09T02:45:15.505655+01:00 PI4bOpenVPN Node-RED[29652]: 9 Jan 02:45:15 - [info] [ONVIF Snapshot:Ctronics] Fetching snapshot from HTTP://192.168.1.47:8080/onvif/device_service
2024-01-09T02:48:15.443772+01:00 PI4bOpenVPN Node-RED[29652]: 9 Jan 02:48:15 - [info] [ONVIF Snapshot:Ctronics] Fetching snapshot from HTTP://192.168.1.47:8080/onvif/device_service
2024-01-09T02:51:15.436431+01:00 PI4bOpenVPN Node-RED[29652]: 9 Jan 02:51:15 - [info] [ONVIF Snapshot:Ctronics] Fetching snapshot from HTTP://192.168.1.47:8080/onvif/device_service
2024-01-09T02:54:15.498536+01:00 PI4bOpenVPN Node-RED[29652]: 9 Jan 02:54:15 - [info] [ONVIF Snapshot:Ctronics] Fetching snapshot from HTTP://192.168.1.47:8080/onvif/device_service
2024-01-09T02:56:47.312255+01:00 PI4bOpenVPN Node-RED[29652]: 9 Jan 02:56:47 - [red] Uncaught Exception:
2024-01-09T02:56:47.313265+01:00 PI4bOpenVPN Node-RED[29652]: 9 Jan 02:56:47 - [error] Error: connect ECONNREFUSED 18.203.57.224:443
2024-01-09T02:56:47.313572+01:00 PI4bOpenVPN Node-RED[29652]:     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)
2024-01-09T02:57:07.562756+01:00 PI4bOpenVPN systemd[1]: Stopped nodered.service - Node-RED graphical event wiring tool.
2024-01-09T02:57:07.632822+01:00 PI4bOpenVPN systemd[1]: Started nodered.service - Node-RED graphical event wiring tool.
2024-01-09T02:57:09.536308+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:09 - [info]
2024-01-09T02:57:09.536771+01:00 PI4bOpenVPN Node-RED[15958]: Welcome to Node-RED
2024-01-09T02:57:09.536918+01:00 PI4bOpenVPN Node-RED[15958]: ===================
2024-01-09T02:57:09.537974+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:09 - [info] Node-RED version: v3.1.1
2024-01-09T02:57:09.539184+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:09 - [info] Node.js  version: v18.19.0
2024-01-09T02:57:09.539688+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:09 - [info] Linux 6.1.0-rpi7-rpi-v7l arm LE
2024-01-09T02:57:10.734990+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:10 - [info] Loading palette nodes
2024-01-09T02:57:15.509491+01:00 PI4bOpenVPN Node-RED[15958]: SmartthingsConfigNode
2024-01-09T02:57:15.510274+01:00 PI4bOpenVPN Node-RED[15958]: Creating directory: /home/pi/.node-red/smartthings/context/
2024-01-09T02:57:16.233174+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:16 - [info] Dashboard version 3.6.2 started at /ui
2024-01-09T02:57:17.475820+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:17 - [info] Settings file  : /home/pi/.node-red/settings.js
2024-01-09T02:57:17.476151+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:17 - [info] HTTP Static    : /home/pi/.node-red/public > /
2024-01-09T02:57:17.482756+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:17 - [info] Context store  : 'default' [module=localfilesystem]
2024-01-09T02:57:17.484531+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:17 - [info] Context store  : 'RAM' [module=memory]
2024-01-09T02:57:17.510213+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:17 - [info] User directory : /home/pi/.node-red
2024-01-09T02:57:17.510744+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:17 - [warn] Projects disabled : editorTheme.projects.enabled=false
2024-01-09T02:57:17.513134+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:17 - [info] Flows file     : /home/pi/.node-red/flows.json
2024-01-09T02:57:17.540001+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:17 - [info] Server now running at http://127.0.0.1:1880/
2024-01-09T02:57:17.600514+01:00 PI4bOpenVPN Node-RED[15958]: 9 Jan 02:57:17 - [warn]
2024-01-09T02:57:17.600734+01:00 PI4bOpenVPN Node-RED[15958]: ---------------------------------------------------------------------
2024-01-09T02:57:17.600857+01:00 PI4bOpenVPN Node-RED[15958]: Your flow credentials file is encrypted using a system-generated key.

If you search the forum for
TCPConnectWrap.afterConnect
you will find this has been reported before with Alexa related nodes. I don't use Alexa so don't know if there is a solution.

Perhaps someone else who knows about Alexa can help.

1 Like

Yes, but why an Uncaught Exception and NR restarting for a normal ERRCONNREFUSED? I am confused.

If a node doesn't handle Uncaught Exceptions, the runtime can be left in an indeterminate state and the safest thing to do is to let it crash. There are a ton of articles and discussions around this but lets just say ignoring errors will almost always leave your application in a bad state, whether that's having a memory leak or leaving sockets hanging or ...

In short, the author of a node should explicitly handle errors and clean up in their nodes - raise an issue on the repository.

1 Like

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