mirror of
https://github.com/craigerl/aprsd.git
synced 2024-12-22 17:45:57 -05:00
Max out the client reconnect backoff to 5
This patch adjusts the backoff mechanism for aprs client reconnect to a max backoff sleep of 5 seconds. This prevents an exponential backoff when connection retrying.
This commit is contained in:
parent
922a6dbb35
commit
26f354b3a9
@ -4,6 +4,7 @@ CHANGES
|
|||||||
v3.1.0
|
v3.1.0
|
||||||
------
|
------
|
||||||
|
|
||||||
|
* Changelog updates for v3.1.0
|
||||||
* Use CONF.admin.web\_port for single launch web admin
|
* Use CONF.admin.web\_port for single launch web admin
|
||||||
* Fixed sio namespace registration
|
* Fixed sio namespace registration
|
||||||
* Update Dockerfile-dev to include uwsgi
|
* Update Dockerfile-dev to include uwsgi
|
||||||
|
@ -49,8 +49,10 @@ class Client:
|
|||||||
@property
|
@property
|
||||||
def client(self):
|
def client(self):
|
||||||
if not self._client:
|
if not self._client:
|
||||||
|
LOG.info("Creating APRS client")
|
||||||
self._client = self.setup_connection()
|
self._client = self.setup_connection()
|
||||||
if self.filter:
|
if self.filter:
|
||||||
|
LOG.info("Creating APRS client filter")
|
||||||
self._client.set_filter(self.filter)
|
self._client.set_filter(self.filter)
|
||||||
return self._client
|
return self._client
|
||||||
|
|
||||||
@ -159,7 +161,11 @@ class APRSISClient(Client):
|
|||||||
LOG.error(f"Unable to connect to APRS-IS server. '{e}' ")
|
LOG.error(f"Unable to connect to APRS-IS server. '{e}' ")
|
||||||
connected = False
|
connected = False
|
||||||
time.sleep(backoff)
|
time.sleep(backoff)
|
||||||
backoff = backoff * 2
|
# Don't allow the backoff to go to inifinity.
|
||||||
|
if backoff > 5:
|
||||||
|
backoff = 5
|
||||||
|
else:
|
||||||
|
backoff += 1
|
||||||
continue
|
continue
|
||||||
LOG.debug(f"Logging in to APRS-IS with user '{user}'")
|
LOG.debug(f"Logging in to APRS-IS with user '{user}'")
|
||||||
self._client = aprs_client
|
self._client = aprs_client
|
||||||
|
@ -265,8 +265,12 @@ def _stats():
|
|||||||
time_format = "%m-%d-%Y %H:%M:%S"
|
time_format = "%m-%d-%Y %H:%M:%S"
|
||||||
stats_dict = stats_obj.stats()
|
stats_dict = stats_obj.stats()
|
||||||
# Webchat doesnt need these
|
# Webchat doesnt need these
|
||||||
del stats_dict["aprsd"]["watch_list"]
|
if "watch_list" in stats_dict["aprsd"]:
|
||||||
del stats_dict["aprsd"]["seen_list"]
|
del stats_dict["aprsd"]["watch_list"]
|
||||||
|
if "seen_list" in stats_dict["aprsd"]:
|
||||||
|
del stats_dict["aprsd"]["seen_list"]
|
||||||
|
if "threads" in stats_dict["aprsd"]:
|
||||||
|
del stats_dict["aprsd"]["threads"]
|
||||||
# del stats_dict["email"]
|
# del stats_dict["email"]
|
||||||
# del stats_dict["plugins"]
|
# del stats_dict["plugins"]
|
||||||
# del stats_dict["messages"]
|
# del stats_dict["messages"]
|
||||||
|
@ -18,7 +18,10 @@ LOG = logging.getLogger("APRSD")
|
|||||||
def magic_word_authenticator(sock):
|
def magic_word_authenticator(sock):
|
||||||
magic = sock.recv(len(CONF.rpc_settings.magic_word)).decode()
|
magic = sock.recv(len(CONF.rpc_settings.magic_word)).decode()
|
||||||
if magic != CONF.rpc_settings.magic_word:
|
if magic != CONF.rpc_settings.magic_word:
|
||||||
raise AuthenticationError(f"wrong magic word {magic}")
|
raise AuthenticationError(
|
||||||
|
f"wrong magic word passed in '{magic}'"
|
||||||
|
f" != '{CONF.rpc_settings.magic_word}'",
|
||||||
|
)
|
||||||
return sock, None
|
return sock, None
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ class APRSDRXThread(APRSDThread):
|
|||||||
client.factory.create().client.stop()
|
client.factory.create().client.stop()
|
||||||
|
|
||||||
def loop(self):
|
def loop(self):
|
||||||
|
LOG.info(f"APRSDRXThread Loop {self._client}:{self._client.client}")
|
||||||
# setup the consumer of messages and block until a messages
|
# setup the consumer of messages and block until a messages
|
||||||
try:
|
try:
|
||||||
# This will register a packet consumer with aprslib
|
# This will register a packet consumer with aprslib
|
||||||
|
Loading…
Reference in New Issue
Block a user