OPCUA unable to execute addFolder opcuAcommand

Hi,

I use some nodes to create an OPC-UA Server which reflect all live data of the machine. It works fine on some computers but today, same code on a new Windows 11 Pro computer doesn't work anymore.

Here is executed code:

// Aller dans Equipment
node.send({
    ...msg,
    payload: { 
        opcuaCommand: "setFolder" 
    },
    topic: 'i=85', // NodeId de l'Equipment
});

// Ajouter le dossier FESP_100141
node.send({
    ...msg,
    payload: {
        opcuaCommand: "addFolder" 
    },
    topic: 'FESP_100141', // Nom du dossier à créer
});

// Aller dans le dossier FESP_100141
node.send({
    ...msg,
    payload: { 
        opcuaCommand: "setFolder" 
    },
    topic: 'FESP_100141',
});

The first setFolder command works fine, but next addFolder returns "Error: Error" without any detail.

image

All addVariable work as well.

Any idea for addFolder issue ?

Also tried with breaks 500ms between commands :

// Aller dans Equipment
setTimeout(() => {
    node.send({
        ...msg,
        payload: { 
            opcuaCommand: "setFolder" 
        },
        topic: 'i=85',
    });

    // Register namespace après avoir mis le contexte dans Equipment
    setTimeout(() => {
        node.send({
            ...msg,
            payload: {
                opcuaCommand: "addFolder"
            },
            topic: 'ns=1;s=FESP_100141',
        });

        // Aller dans FESP_100141 après avoir enregistré le namespace
        setTimeout(() => {
            node.send({
                ...msg,
                payload: { 
                    opcuaCommand: "setFolder" 
                },
                topic: 'ns=1;s=FESP_100141',
            });
        }, 500); // Délai avant de définir le dossier FESP_100141
    }, 500); // DĂ©lai avant d'enregistrer le namespace
}, 500); // DĂ©lai initial pour aller dans Equipment

But the same.

Which node is generating the error?

OpcUa-Server

What node type have you installed to get the opcua server node?

Please select the server node, export it, and paste it here.

Also, if using node-red-contrib-opcua are you using the latest version? I see it was updated last week.

1 Like

Thanks for helping me.

Here’s an extracted, simplified version of the function node code that sends a msg to the server node, which then returns the error:

[{"id":"02b31bae31c48d2a","type":"OpcUa-Server","z":"24dfd0b8da371607","port":"4840","name":"uwgifes16287zs","endpoint":"","users":"users.json","nodesetDir":"","autoAcceptUnknownCertificate":true,"registerToDiscovery":false,"constructDefaultAddressSpace":true,"allowAnonymous":true,"endpointNone":true,"endpointSign":true,"endpointSignEncrypt":true,"endpointBasic128Rsa15":true,"endpointBasic256":true,"endpointBasic256Sha256":true,"maxNodesPerBrowse":0,"maxNodesPerHistoryReadData":0,"maxNodesPerHistoryReadEvents":0,"maxNodesPerHistoryUpdateData":0,"maxNodesPerRead":0,"maxNodesPerWrite":0,"maxNodesPerMethodCall":0,"maxNodesPerRegisterNodes":0,"maxNodesPerNodeManagement":0,"maxMonitoredItemsPerCall":0,"maxNodesPerHistoryUpdateEvents":0,"maxNodesPerTranslateBrowsePathsToNodeIds":0,"maxConnectionsPerEndpoint":20,"maxMessageSize":4096,"maxBufferSize":4096,"maxSessions":20,"x":1080,"y":700,"wires":[["102f49798c433781"]]},{"id":"a68ec2d0a118d90c","type":"function","z":"24dfd0b8da371607","name":"Objects > FESP_numfour","func":"var regByContext = global.get('regByContext');\nconst opcua = flow.get('opcua') || {};\n\n// Aller dans Equipment\nsetTimeout(() => {\n    node.send({\n        ...msg,\n        payload: {\n            opcuaCommand: \"setFolder\"\n        },\n        topic: 'i=85',\n    });\n\n    // Register namespace après avoir mis le contexte dans Equipment\n    setTimeout(() => {\n        node.send({\n            ...msg,\n            payload: {\n                opcuaCommand: \"addFolder\"\n            },\n            topic: 'ns=1;s=data',\n        });\n\n        // Aller dans FESP_100141 après avoir enregistré le namespace\n        setTimeout(() => {\n            node.send({\n                ...msg,\n                payload: {\n                    opcuaCommand: \"setFolder\"\n                },\n                topic: 'ns=1;s=data',\n            });\n        }, 1000); // Délai avant de définir le dossier FESP_100141\n    }, 1000); // Délai avant d'enregistrer le namespace\n}, 500); // Délai initial pour aller dans Equipment","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":830,"y":700,"wires":[["02b31bae31c48d2a"]]},{"id":"74fed476fd5242c0","type":"inject","z":"24dfd0b8da371607","name":"OPC-UA Init","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":645,"y":700,"wires":[["a68ec2d0a118d90c"]],"l":false},{"id":"102f49798c433781","type":"debug","z":"24dfd0b8da371607","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"","statusType":"counter","x":1235,"y":700,"wires":[],"l":false}]

I've confirmed that I'm using the latest version of the node-red-contrib-opcua package.

Could using an older version help? Is it possible that the latest version has a bug?

It is not clear which debug output is showing what is going into the server node, but you don't appear to be passing anything in msg.payload.

Apologies for the confusion; here’s a clearer breakdown:

The first debug output is from the following code:

node.send({
        ...msg,
        payload: {
            opcuaCommand: "setFolder"
        },
        topic: 'i=85',
    });

→ This executes successfully.

After a 1000ms delay, the second debug output (showing the error) is from:

node.send({
            ...msg,
            payload: {
                opcuaCommand: "addFolder"
            },
            topic: 'ns=1;s=data',
        });

→ Here, msg.payload contains opcuaCommand: "addFolder", which triggers the error.

What is in the function is not important here.
As asked before, add a debug node showing what is going into the opcua node and show us what you see. Give the debug node a name so that it is clear which output is which, and set the debug node to output the full message.

Also, as asked before, select the opcua node, export it and paste it here.

Also please stop node red and start it again in a command window, make the error appear, then copy/paste the full command window output here. Copy/paste please. Not screenshot.

Ok,

So, here you have got the debug of what is outputed by function and sent to "PC UA Server" node (Windows console) :

6 Nov 12:43:22 - [info] [debug:Function node debug]
{
  payload: { opcuaCommand: 'setFolder' },
  topic: 'i=85',
  _msgid: 'b3c3228071568694'
}
11:43:23.552Z :address_space                 :1260  modelChangeTransaction
6 Nov 12:43:23 - [error] [OpcUa-Server:OPC UA Server node] Error
6 Nov 12:43:23 - [info] [debug:Function node debug]
{
  payload: { opcuaCommand: 'addFolder', browseName: 'dataFolder' },
  topic: 'ns=1;s=data',
  _msgid: 'b3c3228071568694'
}
6 Nov 12:43:24 - [warn] [OpcUa-Server:OPC UA Server node] OPC UA Server node: Folder not found for topic: ns=1;s=data
6 Nov 12:43:24 - [info] [debug:Function node debug]
{
  payload: { opcuaCommand: 'setFolder' },
  topic: 'ns=1;s=data',
  _msgid: 'b3c3228071568694'
}

Here is the "OPC UA Server" node :

[{"id":"fc8adc2b38b69fb0","type":"OpcUa-Server","z":"24dfd0b8da371607","g":"ea8f423ab0151f6d","port":"4840","name":"OPC UA Server","endpoint":"","users":"users.json","nodesetDir":"","autoAcceptUnknownCertificate":true,"registerToDiscovery":false,"constructDefaultAddressSpace":true,"allowAnonymous":true,"endpointNone":true,"endpointSign":true,"endpointSignEncrypt":true,"endpointBasic128Rsa15":true,"endpointBasic256":true,"endpointBasic256Sha256":true,"maxNodesPerBrowse":0,"maxNodesPerHistoryReadData":0,"maxNodesPerHistoryReadEvents":0,"maxNodesPerHistoryUpdateData":0,"maxNodesPerRead":0,"maxNodesPerWrite":0,"maxNodesPerMethodCall":0,"maxNodesPerRegisterNodes":0,"maxNodesPerNodeManagement":0,"maxMonitoredItemsPerCall":0,"maxNodesPerHistoryUpdateEvents":0,"maxNodesPerTranslateBrowsePathsToNodeIds":0,"maxConnectionsPerEndpoint":20,"maxMessageSize":4096,"maxBufferSize":4096,"maxSessions":20,"x":930,"y":380,"wires":[["80c33821e8c65b4e"]]}]

Full console on start :

6 Nov 12:48:35 - [info]

Bienvenue sur Node-RED
===================

6 Nov 12:48:35 - [info] Node-RED version: v3.1.14
6 Nov 12:48:35 - [info] Node.js  version: v22.11.0
6 Nov 12:48:35 - [info] Windows_NT 10.0.22631 x64 LE
(node:14052) [DEP0059] DeprecationWarning: The `util.log API is deprecated. Please use console.log() with a custom formatter or a third-party logger instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
6 Nov 12:48:35 - [info] Chargement des noeuds de la palette
+-------------------------------------------------------------------------------------+
| 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              |
+-------------------------------------------------------------------------------------+
(node:14052) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
6 Nov 12:48:37 - [info] Fichier de paramètres  : C:\METIER\fesp\settings.js
6 Nov 12:48:37 - [info] Stockage contextuel : 'default' [module=memory]
6 Nov 12:48:37 - [info] RĂ©pertoire utilisateur : C:\METIER\fesp
6 Nov 12:48:37 - [warn] Projets désactivés : editorTheme.projects.enabled=false
6 Nov 12:48:37 - [info] Fichier des flux : C:\METIER\fesp\flows.json
6 Nov 12:48:37 - [info] Le serveur est disponible Ă  l'adresse http://127.0.0.1:80/admin/
6 Nov 12:48:37 - [info] DĂ©marrage des flux
6 Nov 12:48:37 - [info] [socketio-config:47235b74.69f984] CORS Enabled false
6 Nov 12:48:37 - [info] [socketio-config:47235b74.69f984] CORS METHODS [""]
6 Nov 12:48:37 - [info] [socketio-config:47235b74.69f984] CORS ORIGINS "*"
6 Nov 12:48:37 - [info] [socketio-config:47235b74.69f984] Created server bind to Node-RED port
6 Nov 12:48:37 - [info] Flux démarrés
6 Nov 12:48:37 - [info] [aedes broker:d9dc2063ac24bccb] Binding aedes mqtt server on port: 1883
(node:14052) [DEP0044] DeprecationWarning: The `util.isArray` API is deprecated. Please use `Array.isArray()` instead.
6 Nov 12:48:37 - [info] [mqtt-broker:d0036dd2faf5432e] Connecté au courtier : FESP@mqtt://localhost:1883
6 Nov 12:48:38 - [warn] [function:Préparation structure des registres] Arch_CSV_Canal1
6 Nov 12:48:38 - [warn] [function:Préparation structure des registres] Info_PLC
6 Nov 12:48:38 - [warn] [function:Horodatage] mise Ă  jour horloge automate : 6.11.2024 12:48:40
6 Nov 12:48:38 - [warn] [function:Préparation structure des registres] Arch_CSV_Canal1
6 Nov 12:48:38 - [warn] [function:Préparation structure des registres] Info_PLC
6 Nov 12:48:39 - [warn] [function:function 44] [object Object]
6 Nov 12:48:39 - [warn] [function:function 44] [object Object]
6 Nov 12:48:39 - [error] [function:Variables CSS] TypeError: Cannot read properties of undefined (reading 'fullscreen')
6 Nov 12:48:39 - [warn] [function:function 44] [object Object]
6 Nov 12:48:39 - [error] [http response:Envoi HTML] Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
6 Nov 12:48:39 - [info] [debug:OPC UA node debug]
{
  topic: 'Client-connected',
  payload: 'UaBrowser@NB-CBA - Session 1',
  _msgid: 'f45b28975792396c'
}
6 Nov 12:48:39 - [info] [debug:OPC UA node debug]
{
  topic: 'Username',
  payload: 'UaBrowser@NB-CBA - Session 1',
  _msgid: '9b318465a01be969'
}
6 Nov 12:48:39 - [warn] [function:function 44] [object Object]
6 Nov 12:48:39 - [warn] [function:Variables et fonctions globales] sanitizeText Ok
6 Nov 12:48:39 - [warn] [function:Variables et fonctions globales] [object Object]
6 Nov 12:48:39 - [warn] [function:Variables et fonctions globales] settings Ok
Access level string: CurrentRead | HistoryRead |
Access level: 1 user access level: 1 restrictions: 0
Role: 15668 selection was b
Permission string: Browse | Read | ReadRolePermissions | ReadHistory | ReceiveEvents |
Permission flag: 163
Permissions: [{"roleId":15668,"permissions":163}]
Access level string: CurrentRead | CurrentWrite | StatusWrite | HistoryRead | HistoryWrite | SemanticChange
Access level: 63 user access level: 63 restrictions: 0
Role: 15680 selection was o
Permission string: Browse | Read | Write | WriteAttribute | ReadRolePermissions | WriteRolePermissions | ReadHistory | WriteHistorizing | InsertHistory | ReceiveEvents | Call |
Permission flag: 2559
Concatenated permissions: [{"roleId":15668,"permissions":163},{"roleId":15680,"permissions":2559}]
Permissions: [{"roleId":15668,"permissions":163},{"roleId":15680,"permissions":2559}]
Access level string: CurrentRead | CurrentWrite | StatusWrite | HistoryRead | HistoryWrite | SemanticChange
Access level: 63 user access level: 63 restrictions: 0
Role: 16036 selection was e
Permission string: Browse | Read | Write | WriteAttribute | ReadRolePermissions | WriteRolePermissions | ReadHistory | WriteHistorizing | InsertHistory | ReceiveEvents | Call |
Permission flag: 2559
Concatenated permissions: [{"roleId":15668,"permissions":163},{"roleId":15680,"permissions":2559},{"roleId":16036,"permissions":2559}]
Permissions: [{"roleId":15668,"permissions":163},{"roleId":15680,"permissions":2559},{"roleId":16036,"permissions":2559}]
11:48:54.088Z :address_space                 :1260  modelChangeTransaction
6 Nov 12:48:54 - [error] [OpcUa-Server:OPC UA Server] Error
6 Nov 12:48:54 - [info] [debug:Function node debug]
{
  payload: { opcuaCommand: 'addFolder' },
  topic: 'ns=1;s=data',
  _msgid: '38fd4af5a64dcea3',
  _event: 'node:fdd117c2b041fa15',
  accessLevel: 63,
  userAccessLevel: 63,
  accessRestrictions: 0,
  permissions: [
    { roleId: 15668, permissions: 163 },
    { roleId: 15680, permissions: 2559 },
    { roleId: 16036, permissions: 2559 }
  ]
}
Access level string: CurrentRead | HistoryRead |
Access level: 1 user access level: 1 restrictions: 0
Role: 15668 selection was b
Permission string: Browse | Read | ReadRolePermissions | ReadHistory | ReceiveEvents |
Permission flag: 163
Permissions: [{"roleId":15668,"permissions":163}]
Access level string: CurrentRead | CurrentWrite | StatusWrite | HistoryRead | HistoryWrite | SemanticChange
Access level: 63 user access level: 63 restrictions: 0
Role: 15680 selection was o
Permission string: Browse | Read | Write | WriteAttribute | ReadRolePermissions | WriteRolePermissions | ReadHistory | WriteHistorizing | InsertHistory | ReceiveEvents | Call |
Permission flag: 2559
Concatenated permissions: [{"roleId":15668,"permissions":163},{"roleId":15680,"permissions":2559}]
Permissions: [{"roleId":15668,"permissions":163},{"roleId":15680,"permissions":2559}]
Access level string: CurrentRead | CurrentWrite | StatusWrite | HistoryRead | HistoryWrite | SemanticChange
Access level: 63 user access level: 63 restrictions: 0
Role: 16036 selection was e
Permission string: Browse | Read | Write | WriteAttribute | ReadRolePermissions | WriteRolePermissions | ReadHistory | WriteHistorizing | InsertHistory | ReceiveEvents | Call |
Permission flag: 2559
Concatenated permissions: [{"roleId":15668,"permissions":163},{"roleId":15680,"permissions":2559},{"roleId":16036,"permissions":2559}]
Permissions: [{"roleId":15668,"permissions":163},{"roleId":15680,"permissions":2559},{"roleId":16036,"permissions":2559}]
6 Nov 12:48:55 - [warn] [OpcUa-Server:OPC UA Server] OPC UA Server: Folder not found for topic: ns=1;s=data
6 Nov 12:48:55 - [info] [debug:Function node debug]
{
  payload: { opcuaCommand: 'setFolder' },
  topic: 'ns=1;s=data',
  _msgid: '38fd4af5a64dcea3',
  _event: 'node:fdd117c2b041fa15',
  accessLevel: 63,
  userAccessLevel: 63,
  accessRestrictions: 0,
  permissions: [
    { roleId: 15668, permissions: 163 },
    { roleId: 15680, permissions: 2559 },
    { roleId: 16036, permissions: 2559 }
  ]
}
6 Nov 12:48:55 - [info] [debug:OPC UA node debug]
{
  payload: '',
  topic: 'ns=1;s=data',
  _msgid: '38fd4af5a64dcea3',
  _event: 'node:fdd117c2b041fa15',
  accessLevel: 63,
  userAccessLevel: 63,
  accessRestrictions: 0,
  permissions: [
    { roleId: 15668, permissions: 163 },
    { roleId: 15680, permissions: 2559 },
    { roleId: 16036, permissions: 2559 }
  ]
}

Node.js v22 is not currently supported so I suggest you start by dropping back to v20. After installing v20 go into C:\METIER\fesp\ and run
npm rebuild
to rebuild nodes against the new version.

Also, while it is likely that the problem is not related, I suggest fixing the other errors shown in the log. Otherwise you cannot be certain that what you are seeing is not a side effect of one of those.
I also suggest moving to the latest node-red.

Assuming that the problem is still seen after doing all those I think you may have to submit an issue on the node's github page.
If it turns out that the node.js version is the problem then submit an issue saying that so that the authors can fix it before v22 becomes an LTS version.

1 Like

Thank you! I'll go through each of these steps.

Hi Colin,

  • I uninstalled Node.js 22 and reinstalled Node.js 18 LTS.
  • I upgraded Node-RED to 4.0.5, and all node modules were updated as well.
  • I created a new project with only test nodes, yet I’m still encountering the same error without any additional details.

Out of frustration, I decided to try sample flows…

  • I downloaded and tested the sample from this link without modifying the code, and the same error occurred:

At this point, it really seems to be a bug in the current version of node-red-contrib-opcua.
I’m feeling quite discouraged.

Submit an issue, as I suggested. The node is well supported so you should get feedback fairly quickly.

1 Like

Post a link to the issue here so anyone finding this will be able to see it.

You can follow this bug report here :slight_smile:

Thanks to Colin.