Hilscher / node-red-contrib-s7comm

A Node-RED node to communicate with Siemens S7 PLCs.
MIT License
33 stars 11 forks source link

Node-Red crashes after a while: "TypeError: Cannot read property 'readAllItems' of null" #8

Open shmiFesto opened 4 years ago

shmiFesto commented 4 years ago

Hi there,

I use several nodes of node-red-contrib-s7comm for communication with a Siemens S7-1200.

Some of them read data continuously. Unfortunately, NR crashes after a while with the following error:

29 Apr 12:36:23 - [info] Started flows 29 Apr 14:11:31 - [red] Uncaught Exception: 29 Apr 14:11:31 - TypeError: Cannot read property 'readAllItems' of null at singleReading (/data/node_modules/node-red-contrib-s7comm/s7comm.js:767:18) at NodeS7.node.plc.readAllItems [as readDoneCallback] (/data/node_modules/node-red-contrib-s7comm/s7comm.js:773:11) at NodeS7.readResponse (/data/node_modules/node-red-contrib-s7comm/node_modules/nodes7/nodeS7.js:1339:9) at NodeS7.packetTimeout (/data/node_modules/node-red-contrib-s7comm/node_modules/nodes7/nodeS7.js:231:8) at Timeout.<anonymous> (/data/node_modules/node-red-contrib-s7comm/node_modules/nodes7/nodeS7.js:939:24) at ontimeout (timers.js:438:13) at tryOnTimeout (timers.js:300:5) at listOnTimeout (timers.js:263:5) at Timer.processTimers (timers.js:223:10)

Node-Red runs on Docker Desktop (Windows 10). During startup of NR, there is also some error of the s7comm palette:

29 Apr 14:14:54 - [info] Node-RED version: v1.0.6 29 Apr 14:14:54 - [info] Node.js version: v10.20.1 29 Apr 14:14:54 - [info] Linux 4.9.125-linuxkit x64 LE 29 Apr 14:14:55 - [info] Loading palette nodes 29 Apr 14:14:58 - [s7comm-Error] - Installation of Module net-keepalive failed because we might be on the wrong OS. OS=linux 29 Apr 14:14:58 - [s7comm-Info] - Debug configuration for logLevelNodeS7:{"debug":0,"silent":true} 29 Apr 14:14:58 - [s7comm-Info] - Debug configuration for logLevelNodeRED:{"debug":2,"silent":true} 29 Apr 14:15:01 - [info] Dashboard version 2.21.0 started at /ui 29 Apr 14:15:01 - [info] Settings file : /data/settings.js 29 Apr 14:15:01 - [info] HTTP Static : /data/images 29 Apr 14:15:01 - [info] Context store : 'default' [module=memory] 29 Apr 14:15:01 - [info] User directory : /data 29 Apr 14:15:01 - [warn] Projects disabled : editorTheme.projects.enabled=false 29 Apr 14:15:01 - [info] Flows file : /data/flows.json 29 Apr 14:15:01 - [info] Server now running at http://127.0.0.1:1880/ 29 Apr 14:15:01 - [warn]

Could this somehow be related to the crash?

Thanks a lot for your support! Steffen

shmiFesto commented 4 years ago

one additional thing to mention, which could be important: at the same time a second instance of Node-Red, which is running on another device, also uses s7comm nodes to get data from the same S7-1200. This second instance doesn't crash - and also the first (the one mentioned in the first post) seems to run stable for a longer time when the second is switched off...

However, the first instance then at some time crashes with another error:

29 Apr 14:15:01 - [info] Starting flows 2020-04-29 14:15:02: Connecting to modbustcp slave at 192.168.0.81:502 unit_id: 1 2020-04-29 14:15:02: Connecting to modbustcp slave at 192.168.0.81:502 unit_id: 1 29 Apr 14:15:02 - [info] Started flows 29 Apr 15:00:08 - [red] Uncaught Exception: 29 Apr 15:00:08 - RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 1. Received 2 at boundsError (internal/buffer.js:49:9) at Uint8Array.readInt16BE (internal/buffer.js:461:5) at checkRFCData (/data/node_modules/node-red-contrib-s7comm/node_modules/nodes7/nodeS7.js:1448:27) at NodeS7.onResponse (/data/node_modules/node-red-contrib-s7comm/node_modules/nodes7/nodeS7.js:1094:11) at Socket.<anonymous> (/data/node_modules/node-red-contrib-s7comm/node_modules/nodes7/nodeS7.js:370:20) at Socket.emit (events.js:198:13) at addChunk (_stream_readable.js:288:12) at readableAddChunk (_stream_readable.js:269:11) at Socket.Readable.push (_stream_readable.js:224:10) at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

shmiFesto commented 4 years ago

OK, after my last run I must say, that the first instance also crashes after a while with the "TypeError: Cannot read property 'readAllItems' of null" if the second instance is switched off :-(

shmiFesto commented 4 years ago

Hi all, I made another run with more detailed debug information: "logLevelNodeS7": { "debug": 2, "silent": false },

So this is the debug output of the crash:

[21492,518772400 192.168.0.80 S1] ReadResponse called [21492,518927800 192.168.0.80 S1] Time is 0 seconds and 14.7 ms. [21492,519067900 192.168.0.80 S1] Address IB68 has value 86 and quality OK [21492,519181700 192.168.0.80 S1] Address QB64 has value 1 and quality OK [21492,519267600 192.168.0.80 S1] Address DB2,X0.0 has value false and quality OK [21492,519365600 192.168.0.80 S1] Address DB2,X0.1 has value false and quality OK [21492,519452200 192.168.0.80 S1] Address DB2,DWORD2 has value 2000 and quality OK [21492,519549400 192.168.0.80 S1] Address DB2,DWORD6 has value 2000 and quality OK [21492,519604400 192.168.0.80 S1] Address DB2,BYTE10 has value 1 and quality OK [21492,519702000 192.168.0.80 S1] We are calling back our readDoneCallback. [21492,619452400 192.168.0.80 S1] Reading All Items (readAllItems was called) [21492,619583100 192.168.0.80 S1] Calling SRP from RAI [21492,619643400 192.168.0.80 S1] SendReadPacket called [21492,619830000 192.168.0.80 S1] Sending Read Packet [21492,631362900] INVALID READ RESPONSE - DISCONNECTING [21492,631513900] TPKT Length From Header is 48 and RCV buffer length is 7 and COTP length is 2 and data[6] is 128 [21492,631584000] <Buffer 03 00 00 30 02 f0 80> [21492,631739700] ConnectionReset is happening [21492,631940700] INVALID READ RESPONSE - DISCONNECTING [21492,632071100] TPKT Length From Header is 0 and RCV buffer length is 41 and COTP length is 0 and data[6] is 0 [21492,632136600] <Buffer 32 03 00 00 00 02 00 02 00 1b 00 00 04 03 ff 04 00 08 56 00 ff 04 00 08 01 00 ff 04 00 58 04 00 00 00 07 d0 00 00 07 d0 01> [21492,632323400] ConnectionReset is happening [21493,317154500 192.168.0.80 S1] ISO-on-TCP connection DISCONNECTED. [21493,317366700] ConnectionReset is happening [21493,317515400] ConnectionReset is happening [21494,120480200 192.168.0.80 S1] PacketTimeout called with type read and seq 2 [21494,120627700 192.168.0.80 S1] READ TIMEOUT on sequence number 2 [21494,120706800 192.168.0.80 S1] ReadResponse called [21494,120741900] Processing an undefined packet, likely due to timeout error [21494,120982700] Timeout error - zero length packet [21494,121095700 192.168.0.80 S1] Received a ZERO RESPONSE Processing Read Packet due to unrecoverable packet error [21494,121150700] Processing an undefined packet, likely due to timeout error [21494,121226200] Timeout error - zero length packet [21494,121278200 192.168.0.80 S1] Received a ZERO RESPONSE Processing Read Packet due to unrecoverable packet error [21494,121308200] Processing an undefined packet, likely due to timeout error [21494,121341400] Timeout error - zero length packet [21494,121370800 192.168.0.80 S1] Received a ZERO RESPONSE Processing Read Packet due to unrecoverable packet error [21494,121392400 192.168.0.80 S1] Time is 1 seconds and 501.7 ms. [21494,121609800 192.168.0.80 S1] Address IB68 has value 0 and quality BAD 255 [21494,121951800 192.168.0.80 S1] Address QB64 has value 0 and quality BAD 255 [21494,122104300 192.168.0.80 S1] Address DB2,X0.0 has value false and quality BAD 255 [21494,122219900 192.168.0.80 S1] Address DB2,X0.1 has value false and quality BAD 255 [21494,122294200 192.168.0.80 S1] Address DB2,DWORD2 has value 0 and quality BAD 255 [21494,122388500 192.168.0.80 S1] Address DB2,DWORD6 has value 0 and quality BAD 255 [21494,122460700 192.168.0.80 S1] Address DB2,BYTE10 has value 0 and quality BAD 255 [21494,122530700 192.168.0.80 S1] We are calling back our readDoneCallback. 4 May 12:48:29 - [red] Uncaught Exception: 4 May 12:48:29 - TypeError: Cannot read property 'readAllItems' of null at singleReading (/data/node_modules/node-red-contrib-s7comm/s7comm.js:767:18) at NodeS7.node.plc.readAllItems [as readDoneCallback] (/data/node_modules/node-red-contrib-s7comm/s7comm.js:773:11) at NodeS7.readResponse (/data/node_modules/node-red-contrib-s7comm/node_modules/nodes7/nodeS7.js:1339:9) at NodeS7.packetTimeout (/data/node_modules/node-red-contrib-s7comm/node_modules/nodes7/nodeS7.js:231:8) at Timeout.<anonymous> (/data/node_modules/node-red-contrib-s7comm/node_modules/nodes7/nodeS7.js:939:24) at ontimeout (timers.js:438:13) at tryOnTimeout (timers.js:300:5) at listOnTimeout (timers.js:263:5) at Timer.processTimers (timers.js:223:10)

Would be great if anybody could help! Thanks, Steffen

Henkkas52 commented 1 year ago

I experienced the same thing.

S7-comm is running for over 1 year now on Node-RED, but lately more and more times Node-RED crashes after (re)start because of S7-comm, with same result as described above. I think that is due to a lack of maintenance. Finally I found the cause and this is what I wanted to share with you all.

Solution: Don't start with read and/or write requests until there is a stable connection, otherwise Node-RED will crash !! In order to determine if there is a stable connection, take a status node and monitor the status of one S7 node. If the status is 'connected' , only then you can start with read and/or write requests. afbeelding