hjespers / node-red-contrib-nest

Node-Red module for Nest thermostats and smoke detectors
20 stars 15 forks source link

Error causes Node-Red restart #5

Closed JonMurphy closed 8 years ago

JonMurphy commented 8 years ago

I am experience a restart issue with Node-Red due to Nest and and I am not sure how to troubleshoot or even fix the issue.

In the beginning I was getting logged out of Node-Red and then having to log back in. And then I noticed my context.get, flow.get, and global.get variables would get wiped out (set to nothing). From the log files Node-Red is restarting. It appears to be related to a Nest node (node-red-contrib-nest). But I don't know how to go from here. On of the global values is "DeviceMacId" and you'll see that at the end of the log.

A push in the right direction would be greatly appreciated!

This is runnin on a Raspberry Pi (emonPi) with:

This is what I see in the syslog:

Jul 19 10:38:46 emonpi Node-RED[9909]: 19 Jul 10:38:46 - [red] Uncaught Exception:
Jul 19 10:38:46 emonpi Node-RED[9909]: 19 Jul 10:38:46 - TypeError: Cannot call method 'toString' of undefined
Jul 19 10:38:46 emonpi Node-RED[9909]: at Request._callback (/home/pi/data/node-red/node_modules/node-red-contrib-nest/nest/nest.js:96:50)
Jul 19 10:38:46 emonpi Node-RED[9909]: at self.callback (/home/pi/data/node-red/node_modules/node-red-contrib-nest/node_modules/request/request.js:200:22)
Jul 19 10:38:46 emonpi Node-RED[9909]: at Request.emit (events.js:95:17)
Jul 19 10:38:46 emonpi Node-RED[9909]: at Request.onRequestError (/home/pi/data/node-red/node_modules/node-red-contrib-nest/node_modules/request/request.js:831:8)
Jul 19 10:38:46 emonpi Node-RED[9909]: at ClientRequest.emit (events.js:95:17)
Jul 19 10:38:46 emonpi Node-RED[9909]: at CleartextStream.socketErrorListener (http.js:1547:9)
Jul 19 10:38:46 emonpi Node-RED[9909]: at CleartextStream.emit (events.js:95:17)
Jul 19 10:38:46 emonpi Node-RED[9909]: at Socket.onerror (tls.js:1440:17)
Jul 19 10:38:46 emonpi Node-RED[9909]: at Socket.emit (events.js:117:20)
Jul 19 10:38:46 emonpi Node-RED[9909]: at net.js:440:14
Jul 19 10:38:46 emonpi Node-RED[9909]: at process._tickCallback (node.js:419:13)
Jul 19 10:38:46 emonpi systemd[1]: nodered.service: main process exited, code=exited, status=1/FAILURE
Jul 19 10:38:46 emonpi systemd[1]: Unit nodered.service entered failed state.
Jul 19 10:38:46 emonpi systemd[1]: nodered.service holdoff time over, scheduling restart.
Jul 19 10:38:46 emonpi systemd[1]: Stopping Node-RED graphical event wiring tool....
Jul 19 10:38:46 emonpi systemd[1]: Starting Node-RED graphical event wiring tool....
Jul 19 10:38:46 emonpi systemd[1]: Started Node-RED graphical event wiring tool..
Jul 19 10:38:51 emonpi Node-RED[18243]: Welcome to Node-RED
Jul 19 10:38:51 emonpi Node-RED[18243]: ===================
Jul 19 10:38:51 emonpi Node-RED[18243]: 19 Jul 10:38:51 - [info] Node-RED version: v0.13.4
Jul 19 10:38:51 emonpi Node-RED[18243]: 19 Jul 10:38:51 - [info] Node.js  version: v0.10.29
Jul 19 10:38:51 emonpi Node-RED[18243]: 19 Jul 10:38:51 - [info] Linux 4.4.13-v7+ arm LE
Jul 19 10:38:51 emonpi Node-RED[18243]: 19 Jul 10:38:51 - [info] Loading palette nodes
Jul 19 10:39:01 emonpi CRON[18346]: (root) CMD (  [ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean)
Jul 19 10:39:01 emonpi CRON[18347]: (pi) CMD (/home/pi/emonpi/service-runner >> /var/log/service-runner.log 2>&1)
Jul 19 10:39:08 emonpi Node-RED[18243]: 19 Jul 10:39:08 - [warn] ------------------------------------------
Jul 19 10:39:08 emonpi Node-RED[18243]: 19 Jul 10:39:08 - [warn] Failed to register 1 node type
Jul 19 10:39:08 emonpi Node-RED[18243]: 19 Jul 10:39:08 - [warn] Run with -v for details
Jul 19 10:39:08 emonpi Node-RED[18243]: 19 Jul 10:39:08 - [warn] ------------------------------------------
Jul 19 10:39:08 emonpi Node-RED[18243]: 19 Jul 10:39:08 - [info] Settings file  : /home/pi/.node-red/settings.js
Jul 19 10:39:08 emonpi Node-RED[18243]: 19 Jul 10:39:08 - [info] User directory : /home/pi/.node-red
Jul 19 10:39:08 emonpi Node-RED[18243]: 19 Jul 10:39:08 - [info] Flows file : /home/pi/.node-red/flows_emonpi.json
Jul 19 10:39:08 emonpi Node-RED[18243]: 19 Jul 10:39:08 - [info] Server now running at http://127.0.0.1:1880/
Jul 19 10:39:08 emonpi Node-RED[18243]: 19 Jul 10:39:08 - [info] Starting flows
Jul 19 10:39:08 emonpi Node-RED[18243]: 19 Jul 10:39:08 - [info] [smartplug-device:EdiMax Smartplug] Status changed: undefined-->initializing
Jul 19 10:39:13 emonpi Node-RED[18243]: 19 Jul 10:39:13 - [info] Started flows
Jul 19 10:39:14 emonpi Node-RED[18243]: 19 Jul 10:39:14 - [info] [mqtt-broker:19211dbb.e6dee2] Connected to broker: mqtt://localhost:1883
Jul 19 10:39:14 emonpi Node-RED[18243]: 19 Jul 10:39:14 - [info] [smartplug-device:EdiMax Smartplug] Status changed: initializing-->connected
Jul 19 10:39:17 emonpi Node-RED[18243]: 19 Jul 10:39:17 - [warn] [function:9bb1e6b4.644e18] no lastValue
Jul 19 10:40:00 emonpi Node-RED[18243]: 19 Jul 10:40:00 - [warn] [function:Format request] no DeviceMacId
Jul 19 10:40:01 emonpi CRON[18685]: (pi) CMD (/home/pi/emonpi/service-runner >> /var/log/service-runner.log 2>&1)
Jul 19 10:41:00 emonpi Node-RED[18243]: 19 Jul 10:41:00 - [warn] [function:Format request] no DeviceMacId
Jul 19 10:41:01 emonpi CRON[18982]: (pi) CMD (/home/pi/emonpi/service-runner >> /var/log/service-runner.log 2>&1)
Jul 19 10:41:42 emonpi dhcpcd[777]: eth0: fe80::1ab4:30ff:fe24:69cd router available
Jul 19 10:41:55 emonpi dhcpcd[777]: eth0: fe80::1ab4:30ff:fe24:69cd router available
Jul 19 10:42:00 emonpi Node-RED[18243]: 19 Jul 10:42:00 - [warn] [function:Format request] no DeviceMacId
Jul 19 10:42:01 emonpi CRON[19366]: (pi) CMD (/home/pi/emonpi/service-runner >> /var/log/service-runner.log 2>&1)
hjespers commented 8 years ago

This should be fixed in version 0.1.9. When the node received null data responses it was still trying to convert the response to a string, hence the uncaught exception.