I am writing an OPC UA client using Eclipse Milo and stumbled over the following question: how does the client handle the loss of connections.
For monitoring values I do this using a subscription with the SubscriptionManager:
OpcUaClient client = myCreateClient();
List<MonitoredItemCreateRequest> items = myCreateMonitoredItems();
UaSubscription subscription = client.getSubscriptionManager().createSubscription(1_000.0).get();
List<UaMonitoredItem> result = subscription.createMonitoredItems(TimestampsToReturn.Both, items).get();
for (UaMonitoredItem item : result) {
if (!item.getStatusCode().isBad()) {
item.setValueConsumer(value -> System.out.println("Update: " + value));
}
}
Now when I restart my OPC UA server, which is also implemented using Eclipse Milo, then I do see the client reconnecting, but the subscriptions don't get any more updates. In the log I get the following output:
09:11:15.734 [ua-shared-pool-0] DEBUG o.e.m.o.s.c.s.OpcUaSubscriptionManager - Publish service failure: StatusCode{name=Bad_NoSubscription, value=0x80790000, quality=bad}
java.util.concurrent.CompletionException: UaServiceFaultException: status=Bad_NoSubscription, message=There is no subscription available for this session.
<stack-trace-omitted>
…
So it seems that OpcUaSubscriptionManager is aware of the situation, but does not try to re-register those items. Is that to be done manually?