Subject: Re: bug#36725: 26.1; Emacs can't connect to gnu elpa

From: Noam Postavsky <[email-masked]>
Date: Fri, 19 Jul 2019 12:50:38 -0400

Tim Cross <[email-masked]> writes:

> libgnutls-version’s value is 30605
>
> ➜  bin ldd emacs-26.2 | grep gnutls
> libgnutls.so.30 => /usr/lib/x86_64-linux-gnu/libgnutls.so.30
> (0x00007f78d3a1e000)
>
> I still suspect the issue may have been server rather than client. This
> system with the same configuration has been connecting to elpa.gnu.org over
> https since I first built it when 26.2 was released.  It is only today that
> I found https connections to elpa.gnu.org failed.

I believe the actual problem is on the client side, in that Emacs
versions 26.2 and ealier don't handle the EAGAIN error from gnutls
correctly.  Whether or not the EAGAIN actually happens depends on the
precise timing, so it can be affected by all kinds of things.  For
example, there were some reports that setting gnutls-log-level would
stop the bug from happening.

I'm guessing the elpa.gnu.org server was updated recently in a way which
is triggering this bug.  So a whole lot more people are running into it.

> Note also that to be sure, I did a rebuild and  reinstall of emacs just in
> case it had been linked against an older library. This had no effect.
>
> According the the gnutls NEWS file, this version does support 1.3

The only thing I can't explain is why setting gnutls-algorithm-priority
breaks for you on what seems to be a recent libgnutls (I would have
thought it would be useless at worst).  It is reported to work for
others (though it's likely just a coincidence that it affects the timing
in such a way as to avoid EAGAIN errors).

E.g., Bug#34341 and some recent reddit threads:

https://debbugs.gnu.org/34341#19
https://old.reddit.com/r/emacs/comments/cdei4p/failed_to_download_gnu_archive_bad_request/
https://old.reddit.com/r/emacs/comments/cb3wnj/urlretrievesynchronously_returning_400_bad_request/