From: Christian Heller Date: Tue, 7 Oct 2025 10:28:14 +0000 (+0200) Subject: Handle "(Connect timed out)" ERROR, trigger timed retry. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/todo?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=ircplom Handle "(Connect timed out)" ERROR, trigger timed retry. --- diff --git a/src/ircplom/client.py b/src/ircplom/client.py index 8d05ff3..6d29e0f 100644 --- a/src/ircplom/client.py +++ b/src/ircplom/client.py @@ -889,6 +889,12 @@ class Client(ABC, ClientQueueMixin): ).start() self._retry_connect_in_s *= 2 + def consider_retry(self) -> None: + 'Interpret .db.connection_state, on triggers set retry connect.' + if self.db.connection_state.endswith('timed out)')\ + and not self._retry_connect_in_s > 0: + self._retry_connect_in_s = 1 + def close(self) -> None: 'Close connection, wipe memory of its states, reconnect if indicated.' if not self._autojoins: diff --git a/src/ircplom/msg_parse_expectations.py b/src/ircplom/msg_parse_expectations.py index 64c69d8..a1917a5 100644 --- a/src/ircplom/msg_parse_expectations.py +++ b/src/ircplom/msg_parse_expectations.py @@ -534,7 +534,7 @@ MSG_EXPECTATIONS: list[_MsgParseExpectation] = [ 'ERROR', _MsgTok.NONE, ((_MsgTok.ANY, 'setattr_db:connection_state'),), - bonus_tasks=('doafter_close:',)), + bonus_tasks=('do_consider_retry:', 'doafter_close:',)), _MsgParseExpectation( 'PING', diff --git a/src/tests/_timeout_retries.test b/src/tests/_timeout_retries.test index c2ceebf..767029a 100644 --- a/src/tests/_timeout_retries.test +++ b/src/tests/_timeout_retries.test @@ -63,6 +63,19 @@ repeat isupport-clear-in isupport-clear-out , ..$ DISCONNECTED 1 .!$ will retry connecting in 1 seconds repeat conn-full-in conn-full-out +:0:1 ..< ERROR :Closing link: (Connection timed out) +1 ..$ connection_state set to: [Closing link: (Connection timed out)] +1 ..$ isupport cleared +1 ..$ isupport:CHANTYPES set to: [#&] +1 ..$ isupport:PREFIX set to: [(ov)@+] +1 ..$ isupport:USERLEN set to: [10] +1 ..$ connection_state set to: [] +wait 1 +, ..$ DISCONNECTED +1 .!$ will retry connecting in 1 seconds +repeat conn-full-in conn-full-out + +# test retry chain started by "timed out)" ERROR # on second server, check timed auto-retries don't activate after manual intervention > /connect baz.bar.foo:10003 foo:bar baz:foobarbazquux