vinodsr / node-red-contrib-tuya-smart-device

a node-red module for managing tuya smart devices
https://flows.nodered.org/node/node-red-contrib-tuya-smart-device
MIT License
47 stars 15 forks source link

Gateway connection glitch causes restart of Node-Red (uncaught) #126

Open camphamp opened 1 year ago

camphamp commented 1 year ago

Occasionally, I notice Node-Red crashing/restarting and the syslog notes the cause as the "tuya-smart-device" node (syslog):

` Jun 30 10:55:11 raspberrypi Node-RED[4188]: 30 Jun 10:55:10 - [info] [tuya-smart-device:Gateway] startComm(): Connecting to Tuya with params {"id":"MASKED","key":"MASKED","ip":"","issueGetOnConnect":false,"nullPayloadOnJSONError":false,"version":"3.1","issueRefreshOnConnect":false} , findTimeout : 10000 , retryTimeout: 1000

Jun 30 10:55:11 raspberrypi Node-RED[4188]: 30 Jun 10:55:10 - [info] [tuya-smart-device:Gateway] findDevice(): Initiating the find command

Jun 30 10:55:15 raspberrypi Node-RED[4188]: 30 Jun 10:55:15 - [info] [tuya-smart-device:Gateway] findDevice(): Found device, going to connect

Jun 30 10:55:15 raspberrypi Node-RED[4188]: 30 Jun 10:55:15 - [info] [tuya-smart-device:Gateway] Connected to device! name : Gateway, ip :

Jun 30 10:55:52 raspberrypi Node-RED[4188]: 30 Jun 10:55:52 - [red] Uncaught Exception:

Jun 30 10:55:52 raspberrypi Node-RED[4188]: 30 Jun 10:55:52 - [error] Error: socket hang up

Jun 30 10:55:52 raspberrypi Node-RED[4188]: at connResetException (node:internal/errors:705:14)

Jun 30 10:55:52 raspberrypi Node-RED[4188]: at TLSSocket.socketOnEnd (node:_http_client:518:23)

Jun 30 10:55:52 raspberrypi Node-RED[4188]: at TLSSocket.emit (node:events:525:35)

Jun 30 10:55:52 raspberrypi Node-RED[4188]: at endReadableNT (node:internal/streams/readable:1358:12)

Jun 30 10:55:52 raspberrypi Node-RED[4188]: at processTicksAndRejections (node:internal/process/task_queues:83:21)

Jun 30 10:55:52 raspberrypi systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE

Jun 30 10:55:52 raspberrypi systemd[1]: nodered.service: Failed with result 'exit-code'.

Jun 30 10:55:52 raspberrypi systemd[1]: nodered.service: Consumed 18min 19.971s CPU time.

Jun 30 10:56:12 raspberrypi systemd[1]: nodered.service: Scheduled restart job, restart counter is at 7.

Jun 30 10:56:12 raspberrypi systemd[1]: Stopped Node-RED graphical event wiring tool.

Jun 30 10:56:12 raspberrypi systemd[1]: nodered.service: Consumed 18min 19.971s CPU time. `

I installed an "exception catch node" for the flow but it doesn't report any error nor does it prevent the Node-Red crash.

The device that it was in the midst of connecting to is a TUYA Gateway: Product Name GW018-DM

The last Tuya cloud ping from that device stated: signal intensity:-35||Remaining memory:1896128||UTC:1688135839||time zone:-05:00||DST:1688139439

kevocl commented 1 year ago

I have the same issue. When trying to connect to the device the node brings the whole docker container down.

docker logs:

4 Jul 10:54:37 - [info] [tuya-smart-device:Bliss] startComm(): Connecting to Tuya with params {"id":"**MASKED**","key":"**MASKED**","ip":"10.0.0.98","issueGetOnConnect":false,"nullPayloadOnJSONError":false,"version":"3.3","issueRefreshOnConnect":false} , findTimeout :  99983 , retryTimeout:  50000
4 Jul 10:54:37 - [info] [tuya-smart-device:Bliss] findDevice(): Initiating the find command
4 Jul 10:54:42 - [red] Uncaught Exception:
4 Jul 10:54:42 - [error] TypeError: Cannot read properties of undefined (reading 'payload')
    at Socket.<anonymous> (/data/node_modules/tuyapi/index.js:985:30)
    at Socket.emit (node:events:513:28)
    at UDP.onMessage [as onmessage] (node:dgram:930:8)
leodesigner commented 1 year ago

Looks like I have related issue. After a while smart device node hangs in "Connecting" state. It's not possible to reconnect to a device. Only node red redeploy helps.

bigfeetneedbigboots commented 1 year ago

Getting similar/same issue with Node-RED repeatedly crashing after an uncaught exception from this node. Using Tuya thermostats.

Screenshot 2023-09-03 at 3 45 08 pm

stale[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.