python-opcua
python-opcua copied to clipboard
Detecting connection loss
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?
UaExpert client periodically reads state of server (node i=2259). Probably that requires less network traffic than subscription.
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.
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 .
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.
"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?
https://reference.opcfoundation.org/v104/Core/DataTypes/ServerState/
Dead link. It's now https://reference.opcfoundation.org/Core/Part5/v104/docs/12.6