Hi,
I have a problem with reading out data from PLC to make a backup.
I use node-red-contrib-opcua client node and Browser node for it.
The data(Recipes of a machine) are send to specified datablock of Siemens S7-1500 PLC on demand.
There is a raw description how it should works:
1) The recipes are stored on HMI on indices(0-49). First I will write an Index, which data I wish to receive. There is used write request to opc client.
2) Then I should toggle the Export variable to make PLC Export the data for chosen Index. There is used write request to opc client.
3) Then I should read out all prepared data from PLC. I use Browser node for this.
I try it to do in such a structure see pict below.
function22 - prepared the messages and send them to output for OPC UA Client to get data prepared(1) and 2)) and to second output to OPC UA Browser to retrieve the data.
It sends the messages with delay of 2s till all indices(0-49) are covered.
There is a code in function 22:
const delay = 2000; // ms
let i = 0;
let arr1 = ['"ns=3;s="NV_ExpImp_Recipe"."Recipe_data"','ns=3;s="NV_ExpImp_Command"."Index";','ns=3;s="NV_ExpImp_Command"."Export";']; //Array of values for Payloads of three messages needed to receive data from PLC
let arr2 = ['','Int16','Boolean',];//Array of values for Datatypes of three messages needed to receive data from PLC
let arr3 =[0,"true","",1,"true","",2,"true","",3,"true","",4,"true","",5,"true","",
6,"true","",7,"true","",8,"true","",9,"true",10,"true","",11,"true","",
12,"true","",13,"true","",14,"true","",15,"true","",16,"true","",17,"true","",
18,"true","",19,"true","",20,"true","",21,"true","",22,"true","",23,"true","",
24,"true","",25,"true","",26,"true","",27,"true","",28,"true","",29,"true","",
30,"true","",31,"true","",32,"true","",33,"true","",34,"true","",35,"true","",
36,"true","",37,"true","",38,"true","",39,"true","",40,"true","",41,"true","",
42,"true","",43,"true","",44,"true","",45,"true","",46,"true","",47,"true","",
48,"true","",49,"true",];
//Array of values for Topics of three messages needed to receive data from PLC
// Each 2000ms will be send one message to PLC over OPC: 1. to select index, 2. to toggle the
let interval = setInterval( () => {
// Each third message is for second output of functional node - opc browser
let a=((i+1)%3);
if(a==0){
//in case of 3. message use the second output of function node
node.send([null, { payload: arr3[i], topic: arr1[a], datatype: arr2[a] } ]);
}else{
node.send({ payload: arr3[i], topic: arr1[a], datatype: arr2[a] } );
}
i++;
if (i == arr3.length) {//after sending all 150 messages end the automatic sending
clearInterval(interval);
}
}, delay);
function23 just prepare the data to create a file.
I can write Data from 8 Indices to a file and then I become following error and the Node red terminates:
[red] Uncaught Exception:
4 Jun 15:18:58 - [error] Error: expecting a number NaN
at coerceVariantType (C:\Users\inoxcz\.node-red\node_modules\node-opcua-variant\dist\variant.js:631:23)
at constructHook (C:\Users\inoxcz\.node-red\node_modules\node-opcua-variant\dist\variant.js:415:25)
at new Variant (C:\Users\inoxcz\.node-red\node_modules\node-opcua-variant\dist\variant.js:79:26)
at write_action_input (C:\Users\inoxcz\.node-red\node_modules\node-red-contrib-opcua\opcua\102-opcuaclient.js:1870:22)
at OpcUaClientNode.processInputMsg [as _inputCallback] (C:\Users\inoxcz\.node-red\node_modules\node-red-contrib-opcua\opcua\102-opcuaclient.js:768:11)
at C:\ProgramData\npmglobal\node_modules\node-red\node_modules\@node-red\runtime\lib\nodes\Node.js:214:26
at Object.trigger (C:\ProgramData\npmglobal\node_modules\node-red\node_modules\@node-red\util\lib\hooks.js:166:13)
at Node._emitInput (C:\ProgramData\npmglobal\node_modules\node-red\node_modules\@node-red\runtime\lib\nodes\Node.js:206:11)
at Node.emit (C:\ProgramData\npmglobal\node_modules\node-red\node_modules\@node-red\runtime\lib\nodes\Node.js:190:25)
at Node.receive (C:\ProgramData\npmglobal\node_modules\node-red\node_modules\@node-red\runtime\lib\nodes\Node.js:506:10)
After restart I am receiving these messages see log below:
21:57:15.150Z :client_session_impl :1210 ----------------> session Repaired, now redoing original transaction 21:58:15.141Z :client_session_impl :712 Transaction on Invalid Session ReadRequest serviceResult = BadSessionIdInvalid (0x80250000) isReconnecting?= false q= 0 21:58:15.141Z :client_session_impl :1196 attempt to recreate session to reperform a transaction ReadRequest 21:58:15.142Z :client_session_impl :1203 ----------------> Repairing Client Session as Server believes it is invalid now 21:58:15.171Z :client_session_impl :1210 ----------------> session Repaired, now redoing original transaction 21:59:15.141Z :client_session_impl :712 Transaction on Invalid Session ReadRequest serviceResult = BadSessionIdInvalid (0x80250000) isReconnecting?= false q= 0 21:59:15.149Z :client_session_impl :1196 attempt to recreate session to reperform a transaction ReadRequest 21:59:15.150Z :client_session_impl :1203 ----------------> Repairing Client Session as Server believes it is invalid now 21:59:15.175Z :client_session_impl :1210 ----------------> session Repaired, now redoing original transaction 22:00:15.158Z :client_session_impl :712 Transaction on Invalid Session ReadRequest serviceResult = BadSessionIdInvalid (0x80250000) isReconnecting?= false q= 0 22:00:15.158Z :client_session_impl :712 This warning occurred more than 100 times, no more warning will be logged for this context 22:00:15.158Z :client_session_impl :1196 attempt to recreate session to reperform a transaction ReadRequest 22:00:15.158Z :client_session_impl :1196 This warning occurred more than 100 times, no more warning will be logged for this context 22:00:15.159Z :client_session_impl :1203 ----------------> Repairing Client Session as Server believes it is invalid now 22:00:15.160Z :client_session_impl :1203 This warning occurred more than 100 times, no more warning will be logged for this context 22:00:15.184Z :client_session_impl :1210 ----------------> session Repaired, now redoing original transaction 22:00:15.184Z :client_session_impl :1210 This warning occurred more than 100 times, no more warning will be logged for this context
Here are my specifications:
Node-RED version: v4.1.8
Node.js version: v24.15.0
Windows_NT 10.0.22631 x64 LE(Windows 11, 23H2
node-red-contrib-opcua 0.2.350
+-------------------------------------------------------------------------------------+
| Warning: |
| node-opcua-client-crawler module has been deprecated and is not maintained anymore. |
| Please use '@sterfive/crawler' instead. |
| '@sterfive/crawler' is available to the NodeOPCUA Subscription members |
+-------------------------------------------------------------------------------------+
PLC: Siemens SIMATIC S7-1500
Can you help me the way ho to find out the reason why it is crashing and how to fix it?
Many thanks for any piece of Advice.
Petr Duga
