Commit 0122a5e8 authored by Jonathan Becker's avatar Jonathan Becker Committed by oroulet

improve ha client keepalive error handling

parent f1f961f2
...@@ -450,6 +450,10 @@ class KeepAlive: ...@@ -450,6 +450,10 @@ class KeepAlive:
f"Starting keepalive loop for {server_info.url}, checking every {self.timer}sec" f"Starting keepalive loop for {server_info.url}, checking every {self.timer}sec"
) )
while self.is_running: while self.is_running:
if client.uaclient.protocol is None:
server_info.status = ConnectionStates.NO_DATA
_logger.info("No active client")
else:
try: try:
status, slevel = await client.read_values([status_node, slevel_node]) status, slevel = await client.read_values([status_node, slevel_node])
if status != ua.ServerState.Running: if status != ua.ServerState.Running:
...@@ -460,9 +464,12 @@ class KeepAlive: ...@@ -460,9 +464,12 @@ class KeepAlive:
except BadSessionNotActivated: except BadSessionNotActivated:
_logger.warning("Session is not yet activated.") _logger.warning("Session is not yet activated.")
server_info.status = ConnectionStates.NO_DATA server_info.status = ConnectionStates.NO_DATA
except BadSessionClosed: except BadSessionClosed :
_logger.warning("Session is closed.") _logger.warning("Session is closed.")
server_info.status = ConnectionStates.NO_DATA server_info.status = ConnectionStates.NO_DATA
except ConnectionError :
_logger.warning("No connection.")
server_info.status = ConnectionStates.NO_DATA
except asyncio.TimeoutError: except asyncio.TimeoutError:
_logger.warning("Timeout when fetching state") _logger.warning("Timeout when fetching state")
server_info.status = ConnectionStates.NO_DATA server_info.status = ConnectionStates.NO_DATA
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment