python-opcua icon indicating copy to clipboard operation
python-opcua copied to clipboard

Detecting connection loss

Open bitmarker opened this issue 9 years ago • 7 comments

Hello! Is it possible to detect if the server has been turned off or the connection between the server and client was lost? The only way I found is to subscribe to the server time and use the subscription as "watchdog signal". Is there any way to detect if the session has ended?

bitmarker avatar Jan 06 '16 14:01 bitmarker

UaExpert client periodically reads state of server (node i=2259). Probably that requires less network traffic than subscription.

alkor avatar Jan 06 '16 22:01 alkor

Found in OPC UA specs, part 4, 6.5:

The preferred mechanism for a Client to monitor the connection status is through the keep-alive of the Subscription. A Client should subscribe for the State Variable in the ServerStatus to detect shutdown or other failure states. If no Subscription is created or the Server does not support Subscriptions, the connection can be monitored by periodically reading the State Variable.

alkor avatar Jan 06 '16 22:01 alkor

Interesting to see than that kind of thing is in spec. Yes it seems to be the most reliable way to detect connection issues. Many sdk have this built-in, and we may implement it but it requires to remember a bunch of state things ( like running subscriptions). We wait anyway for the port of client to asyncio....

On Wed, Jan 6, 2016, 23:18 Alexander Korolkov [email protected] wrote:

Found in OPC UA specs, part 4, 6.5:

The preferred mechanism for a Client to monitor the connection status is through the keep-alive of the Subscription. A Client should subscribe for the State Variable in the ServerStatus to detect shutdown or other failure states. If no Subscription is created or the Server does not support Subscriptions, the connection can be monitored by periodically reading the State Variable.

— Reply to this email directly or view it on GitHub https://github.com/FreeOpcUa/python-opcua/issues/106#issuecomment-169480265 .

oroulet avatar Jan 07 '16 06:01 oroulet

Maybe this is related. Is it possible to override the server state to force the client to disconnect on it's end? I'm still looking for ways to force all the clients to disconnect from my server safely.

zerox1212 avatar Jan 07 '16 20:01 zerox1212

"A Client should subscribe for the State Variable in the ServerStatus to detect shutdown or other failure states." OK, but what should we do with the value we get?! I got 4 as a value, what does that mean?

ronytesler avatar Nov 25 '21 09:11 ronytesler

https://reference.opcfoundation.org/v104/Core/DataTypes/ServerState/

AndreasHeine avatar Nov 25 '21 09:11 AndreasHeine

Dead link. It's now https://reference.opcfoundation.org/Core/Part5/v104/docs/12.6

alexrudd2 avatar Feb 23 '24 21:02 alexrudd2