Error in huejay

Hi,
Since several days, my flow restarts several times a day (1 - 5 times / day).
I use noed-red v2.05 on a pi4.

Sep 13 14:19:34 PI2 Node-RED[5594]: HuejayError: Huejay: read ECONNRESET
Sep 13 14:19:34 PI2 Node-RED[5594]:     at /home/pi/.node-red/node_modules/huejay/lib/Transport.js:106:15
Sep 13 14:19:34 PI2 Node-RED[5594]:     at processTicksAndRejections (internal/process/task_queues.js:97:5) {
Sep 13 14:19:34 PI2 Node-RED[5594]:   type: undefined
Sep 13 14:19:34 PI2 Node-RED[5594]: }
Sep 13 14:19:34 PI2 Node-RED[5594]: HuejayError: Huejay: read ECONNRESET
Sep 13 14:19:34 PI2 Node-RED[5594]:     at /home/pi/.node-red/node_modules/huejay/lib/Transport.js:106:15
Sep 13 14:19:34 PI2 Node-RED[5594]:     at processTicksAndRejections (internal/process/task_queues.js:97:5) {
Sep 13 14:19:34 PI2 Node-RED[5594]:   type: undefined
Sep 13 14:19:34 PI2 Node-RED[5594]: }
Sep 13 14:19:34 PI2 Node-RED[5594]: 13 Sep 14:19:34 - [red] Uncaught Exception:
Sep 13 14:19:34 PI2 Node-RED[5594]: 13 Sep 14:19:34 - abort(Error: Huejay: read ECONNRESET). Build with -s ASSERTIONS=1 for more info.
Sep 13 14:19:34 PI2 systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE
Sep 13 14:19:34 PI2 systemd[1]: nodered.service: Failed with result 'exit-code'.
Sep 13 14:19:54 PI2 systemd[1]: nodered.service: Service RestartSec=20s expired, scheduling restart.
Sep 13 14:19:54 PI2 systemd[1]: nodered.service: Scheduled restart job, restart counter is at 31.
Sep 13 14:19:54 PI2 systemd[1]: Stopped Node-RED graphical event wiring tool.
Sep 13 14:19:54 PI2 systemd[1]: Started Node-RED graphical event wiring tool.

Due to the log I can see, that the error occurs in huejay. But I have no idea, what happens and why. Does any of you have an idea?

Are you using huejay in a function node or is it used by a contrib node? If you are using it in a function node then you need to catch that exception to stop it crashing node-red.

I do not use it directly in a function node, but I belive it is used by node-red-contrib-huemagic (3.0.0) and node-red-contrib-light (1.0.0)

Restart node-red using
node-red-stop;node-red-start
Post the startup output here. Then wait for it to fail again and post the section showing the errors, show us the last bits of the log before the failure and then until it restarts.

Startup-log

Starting as a systemd service.
13 Sep 17:41:49 - [info]
Welcome to Node-RED
===================
13 Sep 17:41:49 - [info] Node-RED version: v2.0.5
13 Sep 17:41:49 - [info] Node.js  version: v12.22.5
13 Sep 17:41:49 - [info] Linux 5.10.52-v7l+ arm LE
13 Sep 17:41:50 - [info] Loading palette nodes
Initializing HAP-NodeJS v0.9.4...
13 Sep 17:41:57 - [info] Dashboard version 2.30.0 started at /ui
13 Sep 17:41:58 - [warn] ------------------------------------------------------
13 Sep 17:41:58 - [warn] [node-red-node-rbe/rbe] 'rbe' already registered by module node-red
13 Sep 17:41:58 - [warn] ------------------------------------------------------
13 Sep 17:41:58 - [info] Settings file  : /home/pi/.node-red/settings.js
13 Sep 17:41:58 - [info] Context store  : 'default' [module=memory]
13 Sep 17:41:58 - [info] User directory : /home/pi/.node-red
13 Sep 17:41:58 - [warn] Projects disabled : editorTheme.projects.enabled=false
13 Sep 17:41:58 - [warn] Flows file name not set. Generating name using hostname.
13 Sep 17:41:58 - [info] Flows file     : /home/pi/.node-red/flows_PI2.json
13 Sep 17:41:58 - [info] Server now running at http://127.0.0.1:1880/
13 Sep 17:41:58 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
13 Sep 17:41:59 - [info] Starting flows
13 Sep 17:41:59 - [error] [nuki-bridge:887f4c7.93367b] Error: Please check the arguments!
13 Sep 17:42:00 - [error] [nuki-lock-control:11c27462.bbb05c] TypeError: Cannot read property 'getNuki' of null
13 Sep 17:42:00 - [info] Started flows
(node:19058) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Homee]. Use emitter.setMaxListeners() to increase limit
(node:19058) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connected listeners added to [Homee]. Use emitter.setMaxListeners() to increase limit
(node:19058) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 disconnected listeners added to [Homee]. Use emitter.setMaxListeners() to increase limit
(node:19058) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 reconnect listeners added to [Homee]. Use emitter.setMaxListeners() to increase limit
{ maxTime: 5000, serverId: '12390' }
13 Sep 17:42:02 - [info] [AnamicoChangeLight:Flur] light input: {
  "payload": {
    "on": false,
    "allOn": false,
    "anyOn": false,
    "brightness": 100,
    "brightnessLevel": 254,
    "colorTemp": 366,
    "updated": "2021-09-13T17:42:01+02:00"
  },
  "info": {
    "id": "11",
    "lightIds": "20, 21, 22, 23, 24, 25, 26, 27",
    "name": "Flur",
    "type": "Room",
    "class": "Hallway"
  },
  "lastState": false,
  "_msgid": "b34af343287c4328"
}
13 Sep 17:42:02 - [info] [AnamicoChangeLight:Flur] light input response: {
  "on": false,
  "bri": 100
}
13 Sep 17:42:02 - [info] [homee:Homee] connected to homee
13 Sep 17:42:03 - [warn] [ui_level:WC Lux] msg.payload does not contain numeric value
Preparing Advertiser for 'WZ Netatmo 8324' using bonjour-hap backend!
Starting to advertise 'WZ Netatmo 8324' using bonjour-hap backend!
Preparing Advertiser for 'SZ Netatmo 2F06' using bonjour-hap backend!
Starting to advertise 'SZ Netatmo 2F06' using bonjour-hap backend!
{ maxTime: 5000, serverId: '32648' }

The time it may fail can be up to 1 day.

I would start by fixing the errors shown in the startup log.

This was a left configuration node of a tool, which wasn't in use any longer. I removed it. So only warnings remain now.

Starting as a systemd service.
13 Sep 17:57:21 - [info]
Welcome to Node-RED
===================
13 Sep 17:57:21 - [info] Node-RED version: v2.0.5
13 Sep 17:57:21 - [info] Node.js  version: v12.22.5
13 Sep 17:57:21 - [info] Linux 5.10.52-v7l+ arm LE
13 Sep 17:57:22 - [info] Loading palette nodes
Initializing HAP-NodeJS v0.9.4...
13 Sep 17:57:28 - [info] Dashboard version 2.30.0 started at /ui
13 Sep 17:57:29 - [warn] ------------------------------------------------------
13 Sep 17:57:29 - [warn] [node-red-node-rbe/rbe] 'rbe' already registered by module node-red
13 Sep 17:57:29 - [warn] ------------------------------------------------------
13 Sep 17:57:29 - [info] Settings file  : /home/pi/.node-red/settings.js
13 Sep 17:57:29 - [info] Context store  : 'default' [module=memory]
13 Sep 17:57:29 - [info] User directory : /home/pi/.node-red
13 Sep 17:57:29 - [warn] Projects disabled : editorTheme.projects.enabled=false
13 Sep 17:57:29 - [warn] Flows file name not set. Generating name using hostname.
13 Sep 17:57:29 - [info] Flows file     : /home/pi/.node-red/flows_PI2.json
13 Sep 17:57:30 - [info] Server now running at http://127.0.0.1:1880/
13 Sep 17:57:30 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
13 Sep 17:57:30 - [info] Starting flows
13 Sep 17:57:31 - [info] Started flows
(node:20175) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Homee]. Use emitter.setMaxListeners() to increase limit
(node:20175) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connected listeners added to [Homee]. Use emitter.setMaxListeners() to increase limit
(node:20175) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 disconnected listeners added to [Homee]. Use emitter.setMaxListeners() to increase limit
(node:20175) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 reconnect listeners added to [Homee]. Use emitter.setMaxListeners() to increase limit
{ maxTime: 5000, serverId: '12390' }
13 Sep 17:57:33 - [info] [AnamicoChangeLight:Flur] light input: {
  "payload": {
    "on": false,
    "allOn": false,
    "anyOn": false,
    "brightness": 100,
    "brightnessLevel": 254,
    "colorTemp": 366,
    "updated": "2021-09-13T17:57:32+02:00"
  },
  "info": {
    "id": "11",
    "lightIds": "20, 21, 22, 23, 24, 25, 26, 27",
    "name": "Flur",
    "type": "Room",
    "class": "Hallway"
  },
  "lastState": false,
  "_msgid": "0bb3d6a96637e8c6"
}
13 Sep 17:57:33 - [info] [AnamicoChangeLight:Flur] light input response: {
  "on": false,
  "bri": 100
}
13 Sep 17:57:33 - [info] [homee:Homee] connected to homee
13 Sep 17:57:34 - [warn] [ui_level:WC Lux] msg.payload does not contain numeric value
Preparing Advertiser for 'WZ Netatmo 8324' using bonjour-hap backend!
Starting to advertise 'WZ Netatmo 8324' using bonjour-hap backend!
Preparing Advertiser for 'SZ Netatmo 2F06' using bonjour-hap backend!
Starting to advertise 'SZ Netatmo 2F06' using bonjour-hap backend!
{ maxTime: 5000, serverId: '32648' }

You can uninstall node-red-node-rbe, it has been superseded by the filter node. That will remove that warning (it won't cause any problems as it is though).

I will do this today :). Thks

Here the log of the last fail with the log of the restart of the flow.

Sep 14 04:36:38 PI2 Node-RED[21870]: { maxTime: 5000, serverId: '12390' }
Sep 14 04:36:50 PI2 Node-RED[21870]: { maxTime: 5000, serverId: '32648' }
Sep 14 04:41:08 PI2 Node-RED[21870]: HuejayError: Huejay: timeout of 15000ms exceeded
Sep 14 04:41:08 PI2 Node-RED[21870]:     at /home/pi/.node-red/node_modules/huejay/lib/Transport.js:106:15
Sep 14 04:41:08 PI2 Node-RED[21870]:     at runMicrotasks (<anonymous>)
Sep 14 04:41:08 PI2 Node-RED[21870]:     at processTicksAndRejections (internal/process/task_queues.js:97:5)
Sep 14 04:41:08 PI2 Node-RED[21870]:     at runNextTicks (internal/process/task_queues.js:66:3)
Sep 14 04:41:08 PI2 Node-RED[21870]:     at listOnTimeout (internal/timers.js:523:9)
Sep 14 04:41:08 PI2 Node-RED[21870]:     at processTimers (internal/timers.js:497:7) {
Sep 14 04:41:08 PI2 Node-RED[21870]:   type: undefined
Sep 14 04:41:08 PI2 Node-RED[21870]: }
Sep 14 04:41:08 PI2 Node-RED[21870]: HuejayError: Huejay: timeout of 15000ms exceeded
Sep 14 04:41:08 PI2 Node-RED[21870]:     at /home/pi/.node-red/node_modules/huejay/lib/Transport.js:106:15
Sep 14 04:41:08 PI2 Node-RED[21870]:     at runMicrotasks (<anonymous>)
Sep 14 04:41:08 PI2 Node-RED[21870]:     at processTicksAndRejections (internal/process/task_queues.js:97:5)
Sep 14 04:41:08 PI2 Node-RED[21870]:     at runNextTicks (internal/process/task_queues.js:66:3)
Sep 14 04:41:08 PI2 Node-RED[21870]:     at listOnTimeout (internal/timers.js:523:9)
Sep 14 04:41:08 PI2 Node-RED[21870]:     at processTimers (internal/timers.js:497:7) {
Sep 14 04:41:08 PI2 Node-RED[21870]:   type: undefined
Sep 14 04:41:08 PI2 Node-RED[21870]: }
Sep 14 04:41:08 PI2 Node-RED[21870]: 14 Sep 04:41:08 - [red] Uncaught Exception:
Sep 14 04:41:08 PI2 Node-RED[21870]: 14 Sep 04:41:08 - abort(Error: Huejay: timeout of 15000ms exceeded). Build with -s ASSERTIONS=1 for more info.
Sep 14 04:41:08 PI2 systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE
Sep 14 04:41:08 PI2 systemd[1]: nodered.service: Failed with result 'exit-code'.
Sep 14 04:41:28 PI2 systemd[1]: nodered.service: Service RestartSec=20s expired, scheduling restart.
Sep 14 04:41:28 PI2 systemd[1]: nodered.service: Scheduled restart job, restart counter is at 3.
Sep 14 04:41:28 PI2 systemd[1]: Stopped Node-RED graphical event wiring tool.
Sep 14 04:41:28 PI2 systemd[1]: Started Node-RED graphical event wiring tool.
Sep 14 04:41:29 PI2 Node-RED[29859]: 14 Sep 04:41:29 - [info]
Sep 14 04:41:29 PI2 Node-RED[29859]: Welcome to Node-RED
Sep 14 04:41:29 PI2 Node-RED[29859]: ===================
Sep 14 04:41:29 PI2 Node-RED[29859]: 14 Sep 04:41:29 - [info] Node-RED version: v2.0.5
Sep 14 04:41:29 PI2 Node-RED[29859]: 14 Sep 04:41:29 - [info] Node.js  version: v12.22.5
Sep 14 04:41:29 PI2 Node-RED[29859]: 14 Sep 04:41:29 - [info] Linux 5.10.52-v7l+ arm LE
Sep 14 04:41:30 PI2 Node-RED[29859]: 14 Sep 04:41:30 - [info] Loading palette nodes
Sep 14 04:41:35 PI2 Node-RED[29859]: Initializing HAP-NodeJS v0.9.4...
Sep 14 04:41:36 PI2 Node-RED[29859]: 14 Sep 04:41:36 - [info] Dashboard version 2.30.0 started at /ui
Sep 14 04:41:37 PI2 Node-RED[29859]: 14 Sep 04:41:37 - [warn] ------------------------------------------------------
Sep 14 04:41:37 PI2 Node-RED[29859]: 14 Sep 04:41:37 - [warn] [node-red-node-rbe/rbe] 'rbe' already registered by module node-red
Sep 14 04:41:37 PI2 Node-RED[29859]: 14 Sep 04:41:37 - [warn] ------------------------------------------------------
Sep 14 04:41:37 PI2 Node-RED[29859]: 14 Sep 04:41:37 - [info] Settings file  : /home/pi/.node-red/settings.js
Sep 14 04:41:37 PI2 Node-RED[29859]: 14 Sep 04:41:37 - [info] Context store  : 'default' [module=memory]
Sep 14 04:41:37 PI2 Node-RED[29859]: 14 Sep 04:41:37 - [info] User directory : /home/pi/.node-red
Sep 14 04:41:37 PI2 Node-RED[29859]: 14 Sep 04:41:37 - [warn] Projects disabled : editorTheme.projects.enabled=false
Sep 14 04:41:37 PI2 Node-RED[29859]: 14 Sep 04:41:37 - [warn] Flows file name not set. Generating name using hostname.
Sep 14 04:41:37 PI2 Node-RED[29859]: 14 Sep 04:41:37 - [info] Flows file     : /home/pi/.node-red/flows_PI2.json
Sep 14 04:41:37 PI2 Node-RED[29859]: 14 Sep 04:41:37 - [info] Server now running at http://127.0.0.1:1880/
Sep 14 04:41:37 PI2 Node-RED[29859]: 14 Sep 04:41:37 - [warn]
Sep 14 04:41:37 PI2 Node-RED[29859]: ---------------------------------------------------------------------
Sep 14 04:41:37 PI2 Node-RED[29859]: Your flow credentials file is encrypted using a system-generated key.
Sep 14 04:41:37 PI2 Node-RED[29859]: If the system-generated key is lost for any reason, your credentials
Sep 14 04:41:37 PI2 Node-RED[29859]: file will not be recoverable, you will have to delete it and re-enter
Sep 14 04:41:37 PI2 Node-RED[29859]: your credentials.
Sep 14 04:41:37 PI2 Node-RED[29859]: You should set your own key using the 'credentialSecret' option in
Sep 14 04:41:37 PI2 Node-RED[29859]: your settings file. Node-RED will then re-encrypt your credentials
Sep 14 04:41:37 PI2 Node-RED[29859]: file using your chosen key the next time you deploy a change.
Sep 14 04:41:37 PI2 Node-RED[29859]: ---------------------------------------------------------------------
Sep 14 04:41:38 PI2 Node-RED[29859]: 14 Sep 04:41:38 - [info] Starting flows
Sep 14 04:41:38 PI2 Node-RED[29859]: 14 Sep 04:41:38 - [info] Started flows
Sep 14 04:41:38 PI2 Node-RED[29859]: (node:29859) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Homee]. Use emitter.setMaxListeners() to increase limit
Sep 14 04:41:38 PI2 Node-RED[29859]: (node:29859) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connected listeners added to [Homee]. Use emitter.setMaxListeners() to increase limit
Sep 14 04:41:38 PI2 Node-RED[29859]: (node:29859) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 disconnected listeners added to [Homee]. Use emitter.setMaxListeners() to increase limit
Sep 14 04:41:38 PI2 Node-RED[29859]: (node:29859) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 reconnect listeners added to [Homee]. Use emitter.setMaxListeners() to increase limit
Sep 14 04:41:38 PI2 Node-RED[29859]: { maxTime: 5000, serverId: '12390' }
Sep 14 04:41:40 PI2 Node-RED[29859]: 14 Sep 04:41:40 - [info] [AnamicoChangeLight:Flur] light input: {
Sep 14 04:41:40 PI2 Node-RED[29859]:   "payload": {
Sep 14 04:41:40 PI2 Node-RED[29859]:     "on": false,
Sep 14 04:41:40 PI2 Node-RED[29859]:     "allOn": false,
Sep 14 04:41:40 PI2 Node-RED[29859]:     "anyOn": false,
Sep 14 04:41:40 PI2 Node-RED[29859]:     "brightness": 100,
Sep 14 04:41:40 PI2 Node-RED[29859]:     "brightnessLevel": 254,
Sep 14 04:41:40 PI2 Node-RED[29859]:     "colorTemp": 366,
Sep 14 04:41:40 PI2 Node-RED[29859]:     "updated": "2021-09-14T04:41:39+02:00"
Sep 14 04:41:40 PI2 Node-RED[29859]:   },
Sep 14 04:41:40 PI2 Node-RED[29859]:   "info": {
Sep 14 04:41:40 PI2 Node-RED[29859]:     "id": "11",
Sep 14 04:41:40 PI2 Node-RED[29859]:     "lightIds": "20, 21, 22, 23, 24, 25, 26, 27",
Sep 14 04:41:40 PI2 Node-RED[29859]:     "name": "Flur",
Sep 14 04:41:40 PI2 Node-RED[29859]:     "type": "Room",
Sep 14 04:41:40 PI2 Node-RED[29859]:     "class": "Hallway"
Sep 14 04:41:40 PI2 Node-RED[29859]:   },
Sep 14 04:41:40 PI2 Node-RED[29859]:   "lastState": false,
Sep 14 04:41:40 PI2 Node-RED[29859]:   "_msgid": "80ac84cf58741f76"
Sep 14 04:41:40 PI2 Node-RED[29859]: }
Sep 14 04:41:40 PI2 Node-RED[29859]: 14 Sep 04:41:40 - [info] [AnamicoChangeLight:Flur] light input response: {
Sep 14 04:41:40 PI2 Node-RED[29859]:   "on": false,
Sep 14 04:41:40 PI2 Node-RED[29859]:   "bri": 100
Sep 14 04:41:40 PI2 Node-RED[29859]: }
Sep 14 04:41:40 PI2 Node-RED[29859]: 14 Sep 04:41:40 - [info] [homee:Homee] connected to homee
Sep 14 04:41:42 PI2 Node-RED[29859]: 14 Sep 04:41:42 - [warn] [ui_level:WC Lux] msg.payload does not contain numeric value
Sep 14 04:41:43 PI2 Node-RED[29859]: Preparing Advertiser for 'WZ Netatmo 8324' using bonjour-hap backend!
Sep 14 04:41:43 PI2 Node-RED[29859]: Starting to advertise 'WZ Netatmo 8324' using bonjour-hap backend!
Sep 14 04:41:43 PI2 Node-RED[29859]: Preparing Advertiser for 'SZ Netatmo 2F06' using bonjour-hap backend!
Sep 14 04:41:43 PI2 Node-RED[29859]: Starting to advertise 'SZ Netatmo 2F06' using bonjour-hap backend!
Sep 14 04:41:51 PI2 Node-RED[29859]: { maxTime: 5000, serverId: '32648' }

I had hoped there might be more clues there, but apparently not. What does this command show, from your .node-red folder?
npm list huejay

node-red-project@0.0.1 /home/pi/.node-red
└─┬ node-red-contrib-huemagic@3.0.0
  └── huejay@1.9.0 

I appreciate your help!

It is a bug in the huemagic node. All exceptions should be caught by the node in order that node-red does not crash. Looking at the issues on the node's github page I see that there are several unaddressed issues where uncaught exceptions crash node red. Unfortunately it appears that the node is not supported. for example https://github.com/Foddy/node-red-contrib-huemagic/issues/237

1 Like

Thanks for your help. At least I know, that it's a bug. I'll take a look, if I can rebuild my flow without huemagic.

As interim solution I did the hack in in Transport.js (huejay) below. Yes, it's terible as it says in the comment, but it works ;).

return result;
      })
      .catch(error => {
	
	// Prevent network failures to throw errors
	return false;

        if (error instanceof HuejayError) {
          throw error;
        }

        throw new HuejayError({
          message: error.message
        });
	
      });
  }
}

module.exports = Transport;
1 Like