How to know socket of OpcUaClient session is closed?
See original GitHub issueAre 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:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
@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.