PLCHome / node-red-contrib-ads

Beckhoff TwinCat ADS support for Node-Red.
MIT License
15 stars 11 forks source link

Node.js under heavy load when connection down #6

Closed vdwpsmt closed 6 years ago

vdwpsmt commented 6 years ago

configuration: OS: windows server 2016 Node-Red: v 0.19.2 PLC: Twincat 3

Hi, PLC is regulary offline (=normal situation) . In that case Node.js seems te be very busy trying to re-establish the ads connection. So busy that I even can't use Node-red anymore (UI gets no more response from node-red) 2 questions:

kind regards Pascal

PLCHome commented 6 years ago

I'm surprised about this behavior. The node should actually try to restart after 45 seconds if the ADS component does not respond. If an error occurs, the NODE should wait 2 seconds or 20 seconds.

Can you post a part of the log or the cmd output? Maybe I can see what's happening there.

If the PLC is running you have connection?

PLCHome commented 6 years ago

It is up to the windows implementation of the node.js net. Under windows connect is called although the socket triggers an error. As a result, the connect performs too many actions. Let's see how I get the handle

8 Oct 22:37:47 - [info] Starting flows
  node-red-contrib-ads connect: start connect +0ms
  node-red-contrib-ads startTimer: 45000 +0ms
8 Oct 22:37:47 - [info] Started flows
  node-red-contrib-ads connect: callback  undefined +132ms
  node-red-contrib-ads startTimer: 2000 +3ms
  node-red-contrib-ads error: node.adsClient.on  Error: target machine not found
    at getError (d:\rasppi\node-red\node_modules\node-red-contrib-ads\node_modules\node-ads-api\lib\ads.js:1666:13)
    at Object.emitAdsError (d:\rasppi\node-red\node_modules\node-red-contrib-ads\node_modules\node-ads-api\lib\ads.js:1657:13)
    at Object.analyseResponse (d:\rasppi\node-red\node_modules\node-red-contrib-ads\node_modules\node-ads-api\lib\ads.js:205:16)
    at Object.checkResponseStream (d:\rasppi\node-red\node_modules\node-red-contrib-ads\node_modules\node-ads-api\lib\ads.js:190:25)
    at Socket.<anonymous> (d:\rasppi\node-red\node_modules\node-red-contrib-ads\node_modules\node-ads-api\lib\ads.js:124:25)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10) +16ms
  node-red-contrib-ads error: node.adsClient.on  1 +4ms
8 Oct 22:37:47 - [error] [ads-connection:3fd68a9e.3cb1b6] Error ADS: Error: target machine not found
  node-red-contrib-ads error: delete (node.adsClient) +1ms
vdwpsmt commented 6 years ago

Yes, if PLC is running and connected, all is working very well. node-red-contrib-ads version: 1.1.12 node version : 8.11.2

The log will hopefully make things a lot clearer. apparently node-red is restarting after uncaught exception

8 Oct 16:35:31 - [info] Starting flows 8 Oct 16:35:31 - [error] [tls-config:6823cb15.9ffd24] No certificate/key file provided 8 Oct 16:35:31 - [error] [influxdb out:cc3fa701.450908] Configuration missing 8 Oct 16:35:31 - [info] [tcp out:7d4990d4.4b143] connecting to 127.0.0.1:8086 8 Oct 16:35:31 - [info] [tcp out:bd80e7fb.692f18] connecting to 127.0.0.1:8086 8 Oct 16:35:31 - [info] Started flows 8 Oct 16:35:31 - [info] [tcp out:7d4990d4.4b143] connected to 127.0.0.1:8086 8 Oct 16:35:31 - [info] [tcp out:bd80e7fb.692f18] connected to 127.0.0.1:8086 8 Oct 16:35:31 - [info] [mqtt-broker:flespi@1883] Connected to broker: mqtt://... 8 Oct 16:35:31 - [info] [mqtt-broker:svhb desk] Connected to broker: mqtt://... 8 Oct 16:35:31 - [info] [mqtt-broker:flespi.io@8883] Connected to broker: mqtts://... 8 Oct 16:35:32 - [error] [ads-connection:6dfe16c0.24d838] Ads Register Notification live tick timeout 8 Oct 16:35:32 - [error] [ads-connection:6dfe16c0.24d838] Ads Register Notification Sym Tab timeout 8 Oct 16:35:32 - [error] [ads-connection:6dfe16c0.24d838] Error readDeviceInfo: timeout 8 Oct 16:35:32 - [error] [ads-connection:6dfe16c0.24d838] Ads Register Notification timeout 8 Oct 16:35:32 - [error] [ads-connection:6dfe16c0.24d838] Ads Register Notification timeout 8 Oct 16:35:32 - [error] [ads-connection:6dfe16c0.24d838] Ads Register Notification timeout 8 Oct 16:35:32 - [error] [ads-connection:6dfe16c0.24d838] Error ADS: Error: target port not found 8 Oct 16:35:32 - [error] [ads-connection:6dfe16c0.24d838] Ads Register Notification live tick Error 8 Oct 16:35:32 - [error] [ads-connection:6dfe16c0.24d838] Error ADS: Error: target port not found 8 Oct 16:35:32 - [error] [ads-connection:6dfe16c0.24d838] Ads Register Notification Sym Tab Error 8 Oct 16:35:32 - [error] [ads-connection:6dfe16c0.24d838] Error ADS: Error: target port not found 8 Oct 16:35:32 - [red] Uncaught Exception: 8 Oct 16:35:32 - RangeError: Index out of range at checkOffset (buffer.js:977:11) at Buffer.readUInt8 (buffer.js:1015:5) at Object.getDeviceInfoResult (c:...\node-red\node_modules\node-ads-api\lib\ads.js:978:26) at Object.analyseResponse (c:...\node-red\node_modules\node-ads-api\lib\ads.js:229:29) at Object.checkResponseStream (c:...\node-red\node_modules\node-ads-api\lib\ads.js:188:25) at Object.analyseResponse (c:...\node-red\node_modules\node-ads-api\lib\ads.js:256:23) at Object.checkResponseStream (c:...\node-red\node_modules\node-ads-api\lib\ads.js:188:25) at Socket. (c:...\node-red\node_modules\node-ads-api\lib\ads.js:127:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:597:20) 8 Oct 16:35:34 - [info]

PLCHome commented 6 years ago

Yesterday I found a solution. If I manage to test, I can build a version today or tomorrow. But I'm wrong, it's not a difference between windows and linux. It depends on whether the computer is reachable and no ADS is available or the socket can not connect.

PLCHome commented 6 years ago

1.1.13 published

PLCHome commented 6 years ago

I would be happy about a vote