Search code examples
javakotlinopc-uamilo

Eclipse Milo doesn't reconnect to server after lost connection - subscriptions


I am working on subscriptions with Milo and I am trying to make re-connection after connection to server is lost. I subscribe a few thousands of nodes. I added custom SubscriptionListener and after I break a network I receive calls to onPublishFailure() in my SubscriptionListener where I invoke subscriptionManager.clearSubscriptions() and then I resubscribe the same nodes but nothing happens after that.

What's correct approach to handle a lost connection to server for subscriptions?


Solution

  • The correct approach is mostly to do nothing - all of the details of reconnecting are handled automatically.

    The only case you need to handle is when the subscriptions were unable to be transferred after a new session was created. Implement SubscriptionListener#onSubscriptionTransferFailed to re-create any subscription this callback indicates has failed to transfer.

    There's not really any other scenario where you should be manually clearing and re-creating your subscriptions. The onPublishFailure() callback is largely informational and does not require action.