Fail to create subscription on reconnected opcua milo client

272 views Asked by At

Milo client v0.5.2 (same with current v0.6.8) is connected to the opcua server, I restart the server and the milo client reconnects successfully but the subscriptions are lost, so I'm attempting to recreate them by onSessionActive listener.

I even do a getSubscriptionManager().clearSubscriptions() before getSubscriptionManager().createSubscription(scanRate). The createSubscription method ends up with a null Future. So it does not even give an exception, the code execution seems to stop and not return from there and so the invocation to recreate the monitoring subscriptions won't work.

onTransferFailed occures multiple times and I would reestablish the subscriptions for all, so it would be more convenient to call at onSessionActive which is after the onSubscriptionTransferFailed events. Anyway the client.getSubscriptionManager().createSubscription(scanRate) behaves the same way when calling at onSubscriptionTransferFailed: the code execution doesn't return and subscriptions are not made. This is triggered in the first onSubscriptionTransferFailed and no subsequent onSubscriptionTransferFailed events are occuring.

If providing some values of the milo client at onSubscriptionTransferFailed or other point, I could help to better grasp the issue.

My main issue is this full reconnection where the subscriptions are lost and has to be reestablished. There is no way to reinitialize the failed subscription monitors without recreating the subscriptions but that seems to break the Milo client's FSM machinery.

How to go about this problem now?

2

There are 2 answers

9
Kevin Herron On

You should be re-creating them in the SubscriptionListener::onSubscripionTransferFailed callback.

0
obeliksz On

In my experience only having a clear milo opcua client enables the creation of a new subscription after a full disconnect. After onSubscriptionTransferFailed that is detecting any subscription loss its safe to assume that the server is back online.

The subscriptions have to be re-created always after a full disconnect.

Have tried switching to the higher level ManagedSubscription, but that doesn't solve this full disconnect-reconnect resubscription issue as it was already described here:

OPC UA 1.03 did introduce the concept of durable subscriptions, which are supposed to be able to save state and survive restarts, but I don't know of any servers that implement this right now.