node-red / node-red

Low-code programming for event-driven applications
http://nodered.org
Apache License 2.0
18.86k stars 3.3k forks source link

Preventing Node-RED Application Exit on PLC Connection Failure #4703

Closed ryanhaosun closed 2 weeks ago

ryanhaosun commented 1 month ago

Current Behavior

Problem Description:

In one of my Node-RED flows, I'm utilizing the node-red-contrib-s7 node to connect to a PLC. However, when the PLC goes offline or experiences an error, despite multiple reconnection attempts, the Node-RED application exits. Even though other flows are functioning normally, the entire Node-RED application shuts down. The error message received is as follows:

kotlin Copy code [red] Uncaught Exception: 14 May 09:13:35 - [error] Error: read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:209:20) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-red-docker@2.1.4 start: node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data" npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the node-red-docker@2.1.4 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /data/.npm/_logs/2024-05-14T09_13_35_060Z-debug.log Is there a solution to prevent Node-RED from exiting in this scenario, even if the PLC connection is lost?

Expected Behavior

No response

Steps To Reproduce

No response

Example flow

paste your flow here

Environment

knolleary commented 1 month ago

Hi

The only practical fix is for the S7 node to handle it's errors properly. That isn't something the core of Node-RED can do for it.

Uncaught exceptions like this could come from anywhere and the recommended course of action (from node.js) is to restart the runtime as you have no idea what state it is in.

I recommend reporting this against the S7 nodes and see if they are able to provide a fix.

knolleary commented 2 weeks ago

Closing as this is an S7 specific issue