Open nictop17 opened 1 month ago
the namedspace array gets filled in the order of registration of the namespaces only idx 0 and 1 are stable!
clients need to be aware of that and should always store uris (expanded nodeids) instead of the idx... or the namespace array alongside the nodeids, so it can be translated and checked against the server after connect.
Yes, I am of exactly the same opinion.
For this reason, i thought using the NamespaceIndex
instead of the Uri when creating the classes in the ua
module could be a problem. However, the NamespaceArray
is kept in every ua.Client()
and could therefore be used for translation. But Im not sure if this is the case and could be the reason for my error described above
Usage of NamespaceIndex for custom DataType-Classes
When I had two OPC UA servers import the same NodeSets but in different order and wanted to access them with clients, I realized that the handling of custom datatypes by the method
load_data_type_definitions()
could possibly be inconsistent.As can be seen from the following class created by the method, the NamespaceIndex in the NodeId is used to identify the datatype. However, this is dependent on the order of the namespaces on the respective server. The definition of the same datatype can therefore be located on different servers in the same namespace, but does not have to have the same namespaceIndex. If the generated class is now to be used across servers, there are inconsistencies in the way the values are written.
Is this intentional or should the namespaceUri be used here instead of the namespaceIndex to ensure consistency regardless of the import sequence?
I have already tried the parameter
overwrite_existing
of theload_data_type_definitions()
-method, but unfortunately it solves the problem only superficiallyI may also not understand exactly how it works, in which case an explanation could also help :)
Example
When trying to read from the first server and write to the second, UaExpert shows the Value of the Variable with custom datatype![image](https://github.com/user-attachments/assets/fb8ee57f-41e5-43ef-97aa-5591da569047)
Box
as follows:Env
Using
Asyncua==1.1.5