question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to know socket of OpcUaClient session is closed?

See original GitHub issue

Are there some Event/Callback/Listener when socket of OpcUaClient session is closed ?

Consider this scenario:While OPC UA session is connected, unplug the network cable.

I have tried using below methods, but didn’t work.

  • org.eclipse.milo.opcua.sdk.client.OpcUaClient#addSessionActivityListener
  • org.eclipse.milo.opcua.sdk.client.OpcUaClient#addFaultListener

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
TTiacommented, Sep 27, 2018

Hello @frankiezdh, from my experience, Eclipse Milo handles internally the reconnection (StackOverflow).

Something like: UaSubscription subscription = client.getSubscriptionManager().createSubscription(opcPublishingInterval).get(); UInteger subscriptionId = subscription.getSubscriptionId(); client.getSubscriptionManager().addSubscriptionListener(...your listener...);

Then, override UaSubscriptionManager.SubscriptionListener::onSubscriptionTransferFailed and handle the failure (which happens only if the subscription has not been moved to the newly created session, that was generated automatically when the host was back online).

In my implementation, I create a brand new subscription. That’s it.

1reaction
kevinherroncommented, Sep 27, 2018

@TTia is correct.

The closest thing you have is a SessionActivityListener.

Because of the way TCP works there can sometimes be a delay before the connection loss is detected. The current recommendation is to implement some kind of “keep alive” yourself by reading, for example, the server’s CurrentTime and State nodes.

In 0.3 I’ve actually implemented this keep alive in the FSM that manages the session.

Even in 0.3 you’ll still just receive the callback that your session is active or inactive.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OPC-UA Server: How to detect non graceful client close | Forum
This is by design because the session is not supposed to be closed until the server is sure that the client is gone...
Read more >
opc ua - opcua session was closed by client - Stack Overflow
When a server closes the session and socket (as happens when you reinitialize Kepware) the client receives immediate notification that causes ...
Read more >
The issue of session in the 'Reactivating' state.
Reactivating a session happens on the client side. The server keeps a session until the configured session lifetime expires.
Read more >
Client - Getting Started — opcua-lua v0.1.25 documentation
The OPC UA client can operate in two modes, standard blocking socket call ... to the server, open an OPC-UA channel and finally...
Read more >
OPC UA Client Connection Settings - Ignition User Manual 8.1
Connect Timeout. The timeout, in milliseconds, when opening a socket connection to a remote host. Default is 5,000. ; Acknowledge Timeout. The ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found