home · contact · privacy
Handle "(Connect timed out)" ERROR, trigger timed retry. master
authorChristian Heller <c.heller@plomlompom.de>
Tue, 7 Oct 2025 10:28:14 +0000 (12:28 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 7 Oct 2025 10:28:14 +0000 (12:28 +0200)
src/ircplom/client.py
src/ircplom/msg_parse_expectations.py
src/tests/_timeout_retries.test

index 8d05ff3c51fe29387e559c9d8834ca9af4710357..6d29e0f597e8160e6d200db3bbc426fa079ba206 100644 (file)
@@ -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:
index 64c69d80cd496a4720a6a4f4f01e697483388b73..a1917a547e9474f992e6deafccc75453ae92c70c 100644 (file)
@@ -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',
index c2ceebf184d206f1e63d27ea79d92658069febf3..767029a9931930149e5c86a6b04f5a053b0b4359 100644 (file)
@@ -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