From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "J.P." Newsgroups: gmane.emacs.bugs Subject: bug#62044: 30.0.50; ERC 5.5: Auto-reconnect is broken Date: Wed, 08 Mar 2023 08:12:14 -0800 Message-ID: <878rg7ql29.fsf__45993.6248416611$1678292007$gmane$org@neverwas.me> References: <87wn3rg49m.fsf@gmail.com> <87pm9jy8v7.fsf@neverwas.me> <87sfefr4qa.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6394"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-erc@gnu.org, 62044@debbugs.gnu.org To: xoddf2 Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 08 17:13:19 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZwPl-0001Ps-AA for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Mar 2023 17:13:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZwPe-00027z-Om; Wed, 08 Mar 2023 11:13:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZwPY-0001sz-0Y for bug-gnu-emacs@gnu.org; Wed, 08 Mar 2023 11:13:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZwPW-00076g-IH for bug-gnu-emacs@gnu.org; Wed, 08 Mar 2023 11:13:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pZwPW-0000MY-Bq for bug-gnu-emacs@gnu.org; Wed, 08 Mar 2023 11:13:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "J.P." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Mar 2023 16:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62044 X-GNU-PR-Package: emacs Original-Received: via spool by 62044-submit@debbugs.gnu.org id=B62044.16782919521356 (code B ref 62044); Wed, 08 Mar 2023 16:13:02 +0000 Original-Received: (at 62044) by debbugs.gnu.org; 8 Mar 2023 16:12:32 +0000 Original-Received: from localhost ([127.0.0.1]:50024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZwP1-0000Lo-PF for submit@debbugs.gnu.org; Wed, 08 Mar 2023 11:12:32 -0500 Original-Received: from mail-108-mta14.mxroute.com ([136.175.108.14]:34743) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZwOz-0000La-FU for 62044@debbugs.gnu.org; Wed, 08 Mar 2023 11:12:30 -0500 Original-Received: from mail-111-mta2.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta14.mxroute.com (ZoneMTA) with ESMTPSA id 186c1feab82000edb4.001 for <62044@debbugs.gnu.org> (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Wed, 08 Mar 2023 16:12:18 +0000 X-Zone-Loop: d4c2501ff935dc1b574c12e39bf67d15597c1a08c77f X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=neverwas.me ; s=x; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=32hnjIJxVqDOu7in2O4p1mk90+3fhLsXjDwoRo0yg+w=; b=ZY0+/C8dICgmsFk9IQVhROBNhA PUmx9R85OaVVKa7VCVRS8xD5XwUK3fE2jZhebQTkbxAPpsZUypjyYs3GqTJBjpg3ba+agnzKIPhge Xvcbl+tW4e49U2y5bUmoROJuU9kFKzO0G8AfUucxNTLAe0pEI4a+E1DxzOX5RVYagkkxmpLUZKVx7 maXj2dyhOpKcJHWpHJ/k81z1dBLlfM73v6qqHG0kaJiPk2FnGkjdovzxoktkonoXT8T2QOLb1ZIfQ dsbaNYVx+rN9sV9xuFjSDt8RDvQXTMfMtPQqaE84g83jr4qzqO9FI6oPK6j6hae+zjA2FhW+fxcLc HL6vgu7g==; In-Reply-To: <87sfefr4qa.fsf@gmail.com> (xoddf2's message of "Wed, 08 Mar 2023 01:07:25 -0800") X-Authenticated-Id: masked@neverwas.me X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:257547 Archived-At: --=-=-= Content-Type: text/plain xoddf2 writes: > J.P. writes: > >> Hi xoddf2, >> >> [...] For starters, we need to find a recipe, all the way from >> emacs -Q, that triggers the unwanted behavior. That way, we can dispense >> with any possible complications arising from your init.el and any >> third-party packages [...] > > After running emacs-snapshot -Q, I yanked the below Emacs Lisp code into > the *scratch* buffer, evaluated it, then ran M-x erc. I left server and > port at default (irc.libera.chat and 6667, respectively), set nick to > aoddf2, and left the server password blank. I then joined ##test. I > said something in that channel from my usual client, disconnected the VM > from the network in NetworkManager Applet, and then waited a few > minutes. I reconnected and then waited again. ERC had still not > reconnected. Thanks for the logs and the lowdown As with many things IRC, there are two senses of "connectivity" at play here with regard to automatic reconnections: network and application. In your initial report, underlying connectivity is present in some form because ERC reaches the "Logging in as" stage and attempts to send an application payload, though there's no telling how far it actually gets. In your followup, network connectivity is absent due to your "disconnecting the VM", something confirmed by the logs. While I think this simulation is worth exploring, we probably shouldn't assume it's failing in a meaningfully similar way to the real-life connection you're losing to your bouncer, at least not without trying the settings you laid out initially and also seeking a better understanding of what the NM applet is actually doing when you flip the switch. So to keep things sane, we should probably treat auto-reconnecting across connectivity gaps as a wishlist item and auto-reconnecting atop healthy connections as an existing, previously unreported bug. As for the new feature, I've attached a POC patch that you can try if you're willing (usage is self-explanatory, but feel free to modify or iterate as needed). As for the other issue, I think we're going to need some genuine session logs to really get anywhere. That is, we'll likely need you to enable logging and tracing during a real session with your bouncer over a hopefully not-too-prolonged period to capture an actual reconnect sequence failing. But hold off on that for another round unless you're feeling adventurous. Thanks again. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-conditional-erc-server-reconnect-function.patch >From 7c0d22d187400cf2445044f6526814a72b45a86d Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Wed, 8 Mar 2023 06:14:36 -0800 Subject: [PATCH] Add conditional erc-server-reconnect-function * lisp/erc/erc-backend.el (erc--server-reconnect-timer, erc-server-delayed-check-reconnect): Add possible alternate value for option `erc-server-reconnect-function' that only attempts to reconnect after hearing back from the server. Also add helper variable. --- lisp/erc/erc-backend.el | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 567443f5329..d1738e4f92d 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -744,6 +744,47 @@ erc-server-delayed-reconnect (with-current-buffer buffer (erc-server-reconnect)))) +(defvar-local erc--server-reconnect-timeout nil) + +(defun erc-server-delayed-check-reconnect (buffer) + "Wait for internet connectivity before trying to reconnect. +BUFFER is the server buffer for the current connection." + (with-current-buffer buffer + (setq erc--server-reconnect-timeout + (min 300 (* (or erc--server-reconnect-timeout + erc-server-reconnect-timeout) + 2))) + (let ((reschedule + (lambda (proc) + (let ((erc-server-reconnect-timeout + erc--server-reconnect-timeout)) + (with-current-buffer buffer + (delete-process proc) + (erc-display-message nil 'error buffer "Nobody home...") + (erc-schedule-reconnect buffer 0)))))) + (condition-case _ + (make-network-process + :name "*erc-connectivity-check" + :host erc-session-server + :service erc-session-port + :nowait t + :filter + (lambda (proc _) + (delete-process proc) + (with-current-buffer buffer + (setq erc--server-reconnect-timeout nil)) + (run-at-time nil nil #'erc-server-delayed-reconnect buffer)) + :sentinel + (lambda (cproc event) + (with-current-buffer buffer + (pcase event + ("open\n" + (run-at-time nil nil #'send-string + cproc "PING *connect-check*\r\n")) + ("connection broken by remote peer\n" + (funcall reschedule cproc)))))) + (file-error (funcall reschedule nil)))))) + (defun erc-server-filter-function (process string) "The process filter for the ERC server." (with-current-buffer (process-buffer process) -- 2.39.2 --=-=-=--