Search code examples
javasubscriptionopc-uamilo

OPC UA - opcua milo eclipse - reconnection, manual creation of connection, subscription to structure (object)


I am student working on my thesis where I need OPC UA connection. I spent almost week to trying to solve this on my own but without success, so I would like to ask few things and I would be so glad if someone could help me.

1) Subscription to structure (object with fields) I need to subscribe to object which includes two arrays (representing curve) so there is array with x coordinates and array with y coordinates but I have no idea how to do it. I am able to subscribe to them separately but not to whole structure.

2) Is there possibility how to subscribe  not using discovery of endpoints? Why I am asking is that I would like to create connection by my own so even thought the OPC UA server is not running at the moment my app would connect to it when it become available. This is not possible when I use discovery of endpoints because it is not running. But I think the milo should handle the reconnection if I create the endpoint by hand or am I wrong?

Jakub Znamenáček


Solution

    1. You just subscribe to the NodeId of the Variable with a structured value. You'll have to make sure the DataTypeDictionary is being read by the client on startup. See this example. If the server is properly exposing the structure definition in a datatype dictionary there shouldn't be much else required.

    2. You are responsible for retrying until you have an EndpointDescription. Once you have an endpoint and you've created an OpcUaClient instance it will connect and keep reconnecting after the first time you call connect() but you have to get the endpoint and configure the client yourself.