Hello,
Topic: Client Application, Program-language : C# , Framework: .Net
I have created subscriptions and dataMonitoredItems after the opc ua client creates a successfull session to the server. Also I register an eventhandler for the "ConnectionStatusUpdate"- Event of the session object and "DataChanged"-Eventhandler for the created subscriptions.
Now following question:
1. After which ServerConnectionStatusUpdateEventArgs- Values I have to update the NamespaceIndexes? Only after "ServerConnectionStatus.ServerShutdown" or is there some indicating value that tells me to update the namespace table.
2. I have tried to update the namespaceIndex of the monitoredItems nodeId, but it is readonly(nodeId.NamespaceIndex). How can I update the namespaceIndex when it is read only? Also the NodeId object of the monitoredItem is readonly.
3. Do I have to re-register events like DataChanged On subscription again, when namespaceIndex is updated?
Thanks for reply
Regards Shary
Update NamespaceIndex
Moderator: Support Team
- Support Team
- Hero Member
- Posts: 3155
- Joined: 18 Mar 2011, 15:09
Re: Update NamespaceIndex
Hi,
the namespace table is "fix" during runtime of a UA Server. However, (after re-start wt re-configuration) the server may "change" update/modify it's namespace table, including the assigned namespace-index.
On the client side you can be sure that, the namespace table does not change as long as you are connected. However, when you persist NodeIDs (including namespace index), when reconnecting to the same server, you MUST check namespace table fist, AND in case of changes (find namespace URI on different index) replace the index of all your persisted NodeID to again match the correct namespace, BEFORE using/adding Nodes to subscription again (or Read and Write).
If you use Client-SDK such function doing all the magic for you may exist already.
the namespace table is "fix" during runtime of a UA Server. However, (after re-start wt re-configuration) the server may "change" update/modify it's namespace table, including the assigned namespace-index.
On the client side you can be sure that, the namespace table does not change as long as you are connected. However, when you persist NodeIDs (including namespace index), when reconnecting to the same server, you MUST check namespace table fist, AND in case of changes (find namespace URI on different index) replace the index of all your persisted NodeID to again match the correct namespace, BEFORE using/adding Nodes to subscription again (or Read and Write).
If you use Client-SDK such function doing all the magic for you may exist already.
Best regards
Unified Automation Support Team
Unified Automation Support Team
-
- Jr. Member
- Posts: 2
- Joined: 27 Feb 2024, 11:53
Re: Update NamespaceIndex
Ok, thanks for your reply.
Does that mean, when I create a DataMonitedItem and add it to the monitoredItems of a subscription, and add a nodeId to it, that the client sdk will change the namespaceIndex automatically("Magic")?
For example:
List<MonitoredItem> monitoredItems = new List<MonitoredItem>();
ushort index = (ushort)m_Session.NamespaceUris.IndexOf(namespaceUrl); //Index is 6 !!!
NodeId nodeId = new NodeId(identifier, index);
DataMonitoredItem dataMonitoredItem = new DataMonitoredItem(nodeId){}
monitoredItems.Add(dataMonitoredItem);
ushort oldIndex=monitoredItems[0].NodeId.NamespaceIndex //Index is 6
...........................
Server change/update namespaceTable... And the NamespaceIndex is changing from 6 to 2 for the same url
...........................
ushort newIndex=monitoredItems[0].NodeId.NamespaceIndex
Will newIndex have the Value 6 or 2?
I am working with the newest Version of the Client SDK.
Thanks for an answer
Best regards Shary
Does that mean, when I create a DataMonitedItem and add it to the monitoredItems of a subscription, and add a nodeId to it, that the client sdk will change the namespaceIndex automatically("Magic")?
For example:
List<MonitoredItem> monitoredItems = new List<MonitoredItem>();
ushort index = (ushort)m_Session.NamespaceUris.IndexOf(namespaceUrl); //Index is 6 !!!
NodeId nodeId = new NodeId(identifier, index);
DataMonitoredItem dataMonitoredItem = new DataMonitoredItem(nodeId){}
monitoredItems.Add(dataMonitoredItem);
ushort oldIndex=monitoredItems[0].NodeId.NamespaceIndex //Index is 6
...........................
Server change/update namespaceTable... And the NamespaceIndex is changing from 6 to 2 for the same url
...........................
ushort newIndex=monitoredItems[0].NodeId.NamespaceIndex
Will newIndex have the Value 6 or 2?
I am working with the newest Version of the Client SDK.
Thanks for an answer
Best regards Shary
- Support Team
- Hero Member
- Posts: 3155
- Joined: 18 Mar 2011, 15:09
Re: Update NamespaceIndex
Hi,
the .NET Client SDK is recreating the subscription including all the monitored items when the server is restarted (and may have changed it's namespace table). The .NET Client SDK will recreate session, subscription and monitored items (including the namespace index replacement "magic"), so that the client application can just continue as before. Only if the namespace uri is gone completely, the SDK will report an error to the application, indicating that the monitored items could not be re-created (unrecoverable error).
Note: not all our Client-SDKs will recreate the monitored items they have different implementation depth, but at least the channel, the session and the subscription will be reactivated/transfered if possible, but leaving the re-creation of the items to the application.
the .NET Client SDK is recreating the subscription including all the monitored items when the server is restarted (and may have changed it's namespace table). The .NET Client SDK will recreate session, subscription and monitored items (including the namespace index replacement "magic"), so that the client application can just continue as before. Only if the namespace uri is gone completely, the SDK will report an error to the application, indicating that the monitored items could not be re-created (unrecoverable error).
Note: not all our Client-SDKs will recreate the monitored items they have different implementation depth, but at least the channel, the session and the subscription will be reactivated/transfered if possible, but leaving the re-creation of the items to the application.
Best regards
Unified Automation Support Team
Unified Automation Support Team