I use freeopcua c++ (master branch from October 2019) and python-opcua/stable 0.98.6-2 on debian.
When trying to get a child the following way:
root.GetChild(std::vector<std::string>{"0:Objects", "2:MyObject", "2:MyVariable"});
I get an error with status code 0x806f0000 = BadNoMatch when accesing the server in the server-minimal.py example (see below).
If I do it like this:
root.GetChildren()[0].GetChildren()[0].GetChildren()[0]
hand-picking which child is the right one, I can get the child.
This works as well:
auto node = m_uaclient->GetNode(OpcUa::NodeId(2,2));
My server code is just the plain server-minimal.py from python opcua:
import sys
sys.path.insert(0, "..")
import time
from opcua import ua, Server
if __name__ == "__main__":
# setup our server
server = Server()
server.set_endpoint("opc.tcp://0.0.0.0:4840/freeopcua/server/")
# setup our own namespace, not really necessary but should as spec
uri = "http://examples.freeopcua.github.io"
idx = server.register_namespace(uri)
# get Objects node, this is where we should put our nodes
objects = server.get_objects_node()
# populating our address space
myobj = objects.add_object(idx, "MyObject")
myvar = myobj.add_variable(idx, "MyVariable", 6.7)
myvar.set_writable() # Set MyVariable to be writable by clients
# starting!
server.start()
try:
count = 0
while True:
time.sleep(1)
count += 0.1
myvar.set_value(count)
finally:
#close connection, remove subcsriptions, etc
server.stop()
The client is as follows:
m_uaclient = boost::make_unique<OpcUa::UaClient>();
m_uaclient->Connect("opc.tcp://localhost:4840/freeopcua/server/");
OpcUa::Node root = m_uaclient->GetRootNode();
root.GetChild(std::vector<std::string>{"0:Objects", "2:MyObject", "2:MyVariable"});
Would anybody have an idea what the problem could be or how I could proceed narrowing the problem down?