Encountering BadNodeIdInvalid Error When Creating Node Under Namespace 1

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
Matchless6846
Full Member
Full Member
Posts: 8
Joined: 09 Jul 2024, 02:44

Encountering BadNodeIdInvalid Error When Creating Node Under Namespace 1

Post by Matchless6846 »

Hi Support Team,

I have encountered some issues while attempting to create a new node under ns=1:
Exception occurred while adding node ns=1;s=121/Data: UnifiedAutomation.UaBase.StatusException: [BadNodeIdInvalid]
at UnifiedAutomation.UaServer.BaseNodeManager.CreateVariable(RequestContext context, CreateVariableSettings settings)
I understand that namespace index 1 is typically reserved for the server URI. However, due to specific requirements of our project, we need to register nodes under this namespace. Our application architecture necessitates this arrangement for compatibility and integration purposes with other systems that are expecting nodes to be located in namespace 1. Therefore, is it possible to modify the namespace index associated with the Service URI in our OPC UA server configuration? Any guidance or suggestions would be greatly appreciated.

Thank you very much for taking the time to read this post and for any help you can provide.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3255
Joined: 18 Mar 2011, 15:09

Re: Encountering BadNodeIdInvalid Error When Creating Node Under Namespace 1

Post by Support Team »

Hi,

Each namespace is managed by a single NodeManager. Namespace 1 is managed by the CoreNodeManager.
So if there are reasons for adding nodes to namespace 1, you need to create the nodes by calling the specific method at the CoreNodeManager. You could create the nodes in the method OnRootNodeManagerStarted in your ServerManager implementation.

Code: Select all

CoreNodeManager.CreateVariable(DefaultRequestContext, settings); 
In any case, and as you already described yourself, it is not a good idea to create nodes in the NS-1, being a workaround instead of reparing the client that can not deal (hence is not compliant to OPC UA) with the different and multiple namespaces.
Best regards
Unified Automation Support Team

Matchless6846
Full Member
Full Member
Posts: 8
Joined: 09 Jul 2024, 02:44

Re: Encountering BadNodeIdInvalid Error When Creating Node Under Namespace 1

Post by Matchless6846 »

Hi Support Team,

Thank you for your previous guidance! The node creation under ns=1 now works perfectly.

However, we’ve encountered a new issue with data change notifications for nodes in ns=1. Our existing code for reporting value updates resides in a custom NodeManager and uses the following logic:

Code: Select all

GetNodeHandle(
    Server.DefaultRequestContext, 
    node.NodeId, 
    Attributes.Value, 
    out NodeAttributeHandle handle
);
ReportDataChanges(Server.DefaultRequestContext, handle);
This works for nodes in other namespaces but fails to trigger subscriptions for ns=1 nodes. How should we properly notify value changes for nodes under ns=1?

Any insights or code examples would be greatly appreciated.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3255
Joined: 18 Mar 2011, 15:09

Re: Encountering BadNodeIdInvalid Error When Creating Node Under Namespace 1

Post by Support Team »

Hi,

AGAIN (and for other readers): is is NOT a good idea to put custom nodes into NS1, the NS1 is "reserved" for server nodes only (status, diagnostic,configuration), but NOT used for the source data nodes (process values/signals). In NS2 you typically have companion specification (CS) nodes, either DI (DeviceIntegration) followed by other CS, therefore your own custom nodes from your data source will be earliest in NS3.

The method ReportDataChanges is protected, so it cannot be called for the RootNodeManager. To update the values of your own instances in namespace 1 / server namespace you can use:
  • LinkModelToNode
(https://documentation.unified-automation.com/uasdknet/4.1.0/html/classUnifiedAutomation_1_1UaServer_1_1RootNodeManager.html#a92873db5548cbaaa9c90b5f9c16e7978, https://documentation.unified-automation.com/uamodeler/1.7.0/html/howgennetserver_sec.html#howgen_net_server_st3)
  • BindModel
(https://documentation.unified-automation.com/uasdknet/4.1.0/html/classUnifiedAutomation_1_1UaServer_1_1RootNodeManager.html#ad953a67c3ef8ab5872f9323122fe8878, https://documentation.unified-automation.com/uasdknet/4.1.0/html/L3ServerTuMachineDemoServerSetup.html#L4ServerTuMachineDemoServerSetupBind)
  • InternalClient
(https://documentation.unified-automation.com/uasdknet/4.1.0/html/classUnifiedAutomation_1_1UaServer_1_1ServerManager.html#a9ba63af7cce47d84b995537cf670d8b7)
Best regards
Unified Automation Support Team

Post Reply