OPC UA Client node error connection break

I am trying to run node-red continuously to connect with the OpcUa server automatically when the injection machine turns on but I got the error below..

node-red version v3.1.9 and node.js version v18.20.2

22 May 18:44:30 - [error] [OpcUa-Client:b95eecf0ea19f418] Client node error on: error: [" error at active reading: Connection Break"]
22 May 18:44:31 - [error] [OpcUa-Client:b95eecf0ea19f418] Client node error on: error: [" error at active reading: Invalid Channel BadConnectionClosed"]

<--- Last few GCs --->

[14796:000002A718B7FA30] 29651103 ms: Scavenge 4031.9 (4125.5) -> 4020.5 (4126.0) MB, 6.18 / 0.00 ms (average mu = 0.800, current mu = 0.171) task;
[14796:000002A718B7FA30] 29653567 ms: Scavenge 4033.0 (4126.0) -> 4021.2 (4126.7) MB, 6.24 / 0.00 ms (average mu = 0.800, current mu = 0.171) task;
[14796:000002A718B7FA30] 29662571 ms: Mark-Compact 4146.5 (4240.1) -> 4057.7 (4163.8) MB, 6578.87 / 0.00 ms (average mu = 0.719, current mu = 0.617) task; scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

1: 00007FF6F330663B node::SetCppgcReference+18123
2: 00007FF6F32783E4 v8::base::CPU::num_virtual_address_bits+89412
3: 00007FF6F3CEFA81 v8::Isolate::ReportExternalAllocationLimitReached+65
4: 00007FF6F3CD91D8 v8::Function::Experimental_IsNopFunction+1336
5: 00007FF6F3B3AC20 v8::Platform::SystemClockTimeMillis+659328
6: 00007FF6F3B37CA8 v8::Platform::SystemClockTimeMillis+647176
7: 00007FF6F3AF38A8 v8::Platform::SystemClockTimeMillis+367624
8: 00007FF6F32000B3 ENGINE_get_load_privkey_function+4803
9: 00007FF6F31FEA66 node::TriggerNodeReport+82086
10: 00007FF6F336C09B uv_update_time+491
11: 00007FF6F336BC14 uv_run+900
12: 00007FF6F333CB15 node::SpinEventLoop+405
13: 00007FF6F3224982 ENGINE_get_load_privkey_function+154514
14: 00007FF6F32BCD6D node::Start+4909
15: 00007FF6F32BBA70 node::Start+48
16: 00007FF6F307D96C AES_cbc_encrypt+151452
17: 00007FF6F44FF1BC inflateValidate+17308
18: 00007FFE727A7344 BaseThreadInitThunk+20
19: 00007FFE731E26B1 RtlUserThreadStart+33

Seems related to #4678.

Does the error occur when you turn it on or when you turn it off?

Does it work if the machine is already on when you start node-red?

Change the inject node to only fire when you click the button. Does it fail if you don't click it? Does it fail if you then click it?

When I start node-red to run constinuosly I intend to connect automatically to the machine when it turns on.

The error occur when the machine stop the production for a long time or turn off.

When the machine is already on and I start node-red it's work.

If the inject node only fire when click it works if the machine is on.

If you disconnect the wire out of the client node and just connect it to debug node instead, does it still fail when the machine turns off?

You have not said what happens when the machine turns off. Does it immediately crash or not until you click the inject?

Yes, the fail is related with the opc ua server and client connection, after client node isn't important.

When machine turns off it will try to reconnect every 30 sec till crash

Are you certain about that?

If you are certain then I think you will have to submit an issue on the node's github page.

Yes, certainly. Thanks!

How long is that?

And what frequency is the inject node running? Every 100ms? Every 1s?

I have a theory you are causing this issue.

Consider this, the inject runs every 100ms, and calls 15 network type nodes. All 15 nodes attempt to do a network request to the OPCUA server. They get eventually timeout, but all the while you keep inputting msgs into them, 15 more, 15 more, 15 more until :boom:

It is just a theory but there may be something in it.

You might want to see if there is some way of determining the connection status (usually a status node pointed at the OPC UA Client node can work) - then add a switch after the inject to inhibit messages if the connection is offline & avoid filling the memory with queued requests.

I don´t know how long precisely, I'll try to check.

The frequency is every 50ms.

I´m trying to develop a way to handle the connection status but I received the error: cannot read properties of undefined (reading 'text')

let errorOccurredBefore = context.get('errorOccurredBefore') || false;
let error = msg.error;
let status = msg.status;
let text = msg.status.text;
if (error === "Error: Invalid Channel BadConnectionClosed" && !errorOccurredBefore) {
msg.topic = "Reconnect";
msg.action = "reconnect";
msg.opcUAEndpoint = {
credentials: {},
endpoint: "opc.tcp:xxxxxxx",
securityPolicy: "None",
securityMode: "None",
login: true,
user: "user",
password: "password"
};
context.set('errorOccurredBefore', true);
} else {
context.set('errorOccurredBefore', false);
}
if (msg.status.text.includes('BadConnect' || 'Connection Break')) {
return { action: "reconnect", topic: "reconnect" }
}
return msg;

did you set the status node to ONLY point at the singe client node?

To figure things out, you can use node.warn({ stuff you want to inspect }) inside the function at key points.

Yes, I set to only point at client node. Thank you Steve-Mcl

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.