Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [milo-dev] Best practices for a permanent connection

Daniele,

In theory it should be enough to create a connection one time and then leave it indefinitely. The client is built to automatically keep the connection alive and to reconnect and either resume an existing or establish a new session any time it disconnects. This behavior should continue until you've explicitly disconnected the client.

What you do need to is add a SubscriptionListener (client.getSubscriptionManager().addSubscriptionListener(...)) and be sure to implement the onSubscriptionTransferFailed() method. This will get called when a reconnect happens and either the server doesn't support subscription transfers or the subscriptions no longer exist (e.g. because the server was restarted). You need to re-create the Subscription and its MonitoredItems in this case.

For your own information you can also periodically read or subscribe to the server's CurrentTime and State variables and/or add a SessionActivityListener to the client, which will be notified any time a session is activated or goes inactive. This is mostly for informational purposes as the client will automatically handle re-establishing a session.

We use Milo in the same basic scenario where I work and there are generally no issues, and the servers in the Siemens PLCs (1500s, anyway) seem to be pretty good. The OPC UA server in them does restart entirely every time a download happens, though, so you will definitely need to be re-creating subscriptions.

On Sun, Jan 26, 2020 at 5:19 AM Daniele Menozzi <menoz.zone+eclipse@xxxxxxxxx> wrote:
Hello all,
my name's Daniele, I'm from Italy and I'm using milo in industrial scenarios, more specifically in a java daemon that is permanently connected to a Opcua server (hosted in a Siemens PLC).

Everything works flawlessly, but I was wandering what are the best practices in order to establish a permanent connection from java to a Opcua server that could last for weeks, months or even years.

It is enough to create/connect one milo client once and do no more checks? Should I trust it to check for every connection loss and various problems, and reconnect automagically when needed?

Important info: I use subscriptions, so I think I should do as told here [1] to renew subscriptions once in a while, is that correct?

Anything else I should worry about or check from time to time?

Thank you in advance,
Daniel



_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev

Back to the top