Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Transparently reconnect to servers after a system suspend
@ 2016-10-15  7:43 Sebastian Krause
  2016-10-15 17:46 ` Eric Abrahamsen
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Krause @ 2016-10-15  7:43 UTC (permalink / raw)
  To: info-gnus-english

Hi,

I have one IMAP and two NNTP servers configured in Gnus, all over
SSL using the integrated GnuTLS. When I put my laptop into
suspend-to-RAM for a while, the TCP connections will obviously drop
eventually, but Gnus doesn't recognize this, so pressing 'g' after
the system wake-up will cause Gnus to hang waiting for the TCP
connections to respond. I usually resolve that by restarting Gnus
with 'C-g' and 'R'.

Is there a way for Gnus to quickly detect dropped TCP connections
and transparently reconnect when I try to update the group list?

Sebastian


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Transparently reconnect to servers after a system suspend
  2016-10-15  7:43 Transparently reconnect to servers after a system suspend Sebastian Krause
@ 2016-10-15 17:46 ` Eric Abrahamsen
  2016-10-15 18:47   ` Sebastian Krause
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Abrahamsen @ 2016-10-15 17:46 UTC (permalink / raw)
  To: info-gnus-english

Sebastian Krause <sebastian@realpath.org> writes:

> Hi,
>
> I have one IMAP and two NNTP servers configured in Gnus, all over
> SSL using the integrated GnuTLS. When I put my laptop into
> suspend-to-RAM for a while, the TCP connections will obviously drop
> eventually, but Gnus doesn't recognize this, so pressing 'g' after
> the system wake-up will cause Gnus to hang waiting for the TCP
> connections to respond. I usually resolve that by restarting Gnus
> with 'C-g' and 'R'.
>
> Is there a way for Gnus to quickly detect dropped TCP connections
> and transparently reconnect when I try to update the group list?

This has been annoying people for a very long time, but I don't think
there's any clean solution to the problem. Gnus doesn't actually know
that you've suspended and woken your computer, so it doesn't have any
reason to suspect the connections are down. I think we'd have to ping
servers on a timer, or maybe run a clock in lisp and periodically check
it against system time (to see if execution was suspended for a while).
Nothing immediately presents itself as The Right Solution, so no one's
done anything...

A lighter-weight solution than a full restart is using "z", for
gnus-group-suspend. That will close all the servers, which will be
re-opened the next time you "g". In fact, all you really need is:

(dolist (elem gnus-opened-servers)
  (gnus-close-server (car elem))
  (setcar (cdr elem) 'closed))

Eric



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Transparently reconnect to servers after a system suspend
  2016-10-15 17:46 ` Eric Abrahamsen
@ 2016-10-15 18:47   ` Sebastian Krause
  2016-10-16  4:04     ` Eric Abrahamsen
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Krause @ 2016-10-15 18:47 UTC (permalink / raw)
  To: info-gnus-english

Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
> This has been annoying people for a very long time, but I don't think
> there's any clean solution to the problem. Gnus doesn't actually know
> that you've suspended and woken your computer, so it doesn't have any
> reason to suspect the connections are down. I think we'd have to ping
> servers on a timer, or maybe run a clock in lisp and periodically check
> it against system time (to see if execution was suspended for a while).
> Nothing immediately presents itself as The Right Solution, so no one's
> done anything...

I guess The Right Solution would be if Emacs would provide access to
the operating system's sleep/wake notifications (e.g. on macOS:
https://developer.apple.com/library/content/qa/qa1340/_index.html)
and tell Gnus about a system wakeup. Gnus could then just close all
connections each time it received such a notification. But it
doesn't look like there's anything like that in Emacs.

The second best thing I can think of is TCP keepalive with much
lower values for tcp_keepalive_time and tcp_keepalive_intvl. Gnus
actually enables :keepalive in its network sockets (e.g. in nntp.el
and nnimap.el), but the default values for the first keepalive
package on Linux and Windows is two hours of inactivity, and even
then it will take more than 10 minutes of no response until the OS
actually closes the connection. It's actually possible to lower the
keepalive parameters per socket, but again it doesn't seem like
Emacs provides the possibility to do that in elisp.

> A lighter-weight solution than a full restart is using "z", for
> gnus-group-suspend. That will close all the servers, which will be
> re-opened the next time you "g".

Weird, pressing "z" in the *Group* buffer just closes Gnus here.

Sebastian


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Transparently reconnect to servers after a system suspend
  2016-10-15 18:47   ` Sebastian Krause
@ 2016-10-16  4:04     ` Eric Abrahamsen
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Abrahamsen @ 2016-10-16  4:04 UTC (permalink / raw)
  To: info-gnus-english

Sebastian Krause <sebastian@realpath.org> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
>> This has been annoying people for a very long time, but I don't think
>> there's any clean solution to the problem. Gnus doesn't actually know
>> that you've suspended and woken your computer, so it doesn't have any
>> reason to suspect the connections are down. I think we'd have to ping
>> servers on a timer, or maybe run a clock in lisp and periodically check
>> it against system time (to see if execution was suspended for a while).
>> Nothing immediately presents itself as The Right Solution, so no one's
>> done anything...
>
> I guess The Right Solution would be if Emacs would provide access to
> the operating system's sleep/wake notifications (e.g. on macOS:
> https://developer.apple.com/library/content/qa/qa1340/_index.html)
> and tell Gnus about a system wakeup. Gnus could then just close all
> connections each time it received such a notification. But it
> doesn't look like there's anything like that in Emacs.
>
> The second best thing I can think of is TCP keepalive with much
> lower values for tcp_keepalive_time and tcp_keepalive_intvl. Gnus
> actually enables :keepalive in its network sockets (e.g. in nntp.el
> and nnimap.el), but the default values for the first keepalive
> package on Linux and Windows is two hours of inactivity, and even
> then it will take more than 10 minutes of no response until the OS
> actually closes the connection. It's actually possible to lower the
> keepalive parameters per socket, but again it doesn't seem like
> Emacs provides the possibility to do that in elisp.

You could raise both of these questions in emacs.devel and see what they
say -- I don't know too much about it. My guess is that these questions
have been discussed before, but I don't know off the top of my head.

>> A lighter-weight solution than a full restart is using "z", for
>> gnus-group-suspend. That will close all the servers, which will be
>> re-opened the next time you "g".
>
> Weird, pressing "z" in the *Group* buffer just closes Gnus here.

`gnus-group-suspend' closes all the servers *and* buries all Gnus
buffers. It's lighter weight because, unlike "R", it won't have to
re-read all your init files next time you get new news. I generally
don't want my buffers buried, so I just use the code snippet I posted,
in my own function.

E



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-16  4:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-15  7:43 Transparently reconnect to servers after a system suspend Sebastian Krause
2016-10-15 17:46 ` Eric Abrahamsen
2016-10-15 18:47   ` Sebastian Krause
2016-10-16  4:04     ` Eric Abrahamsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).