From 560e1527425153088d7d10cbdcfa5ec5479898d5 Mon Sep 17 00:00:00 2001 From: Hemna Date: Mon, 13 Sep 2021 13:22:06 -0400 Subject: [PATCH] Fixed issue of aprs-is missing keepalive Started noticing that aprs-is keepalive messages just stop getting sent. This causes aprsd to basically disconnect from the APRS network. Added a check into the KeepAlive thread to restart the aprs-is connecter if the last time we got a keepalive from apris is > 5 minutes. --- aprsd/threads.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/aprsd/threads.py b/aprsd/threads.py index fbe47f3..1132c0a 100644 --- a/aprsd/threads.py +++ b/aprsd/threads.py @@ -89,6 +89,8 @@ class KeepAliveThread(APRSDThread): tracemalloc.start() super().__init__("KeepAlive") self.config = config + max_timeout = {"hours": 0.0, "minutes": 5, "seconds": 0} + self.max_delta = datetime.timedelta(**max_timeout) def loop(self): if self.cntr % 60 == 0: @@ -126,6 +128,19 @@ class KeepAliveThread(APRSDThread): len(thread_list), ) LOG.info(keepalive) + + # See if we should reset the aprs-is client + # Due to losing a keepalive from them + delta_dict = utils.parse_delta_str(last_msg_time) + delta = datetime.timedelta(**delta_dict) + + if delta > self.max_delta: + # We haven't gotten a keepalive from aprs-is in a while + # reset the connection.a + if not kissclient.KISSClient.kiss_enabled(self.config): + LOG.warning("Resetting connection to APRS-IS.") + client.Client().reset() + # Check version every hour delta = now - self.checker_time if delta > datetime.timedelta(hours=1):