onion
onion copied to clipboard
Gets stuck at gnutls_handshake()
I am using Debian 11 (testing) with gnutls installed by apt install gnutls-dev
. Note that previously I use Debian 10 (stable), I upgrade to Debian testing only because I would like to try newer version of gnutls
.
My Onion instance will get stuck after running for a few days (i.e., it does not respond to any incoming connections). I investigated it for a while and it turns out to be the issue of gnutls_handshake()
:
https://github.com/davidmoreno/onion/blob/de8ea938342b36c28024fd8393ebc27b8442a161/src/onion/https.c#L222-L225
I revised the above section to:
do{
ONION_DEBUG("gnutls_handshake()'ing\n");
ret = gnutls_handshake (session);
ONION_DEBUG("gnutls_handshake()'ed, ret=%d, strerror=%s\n", ret,gnutls_strerror (ret));
// https://gnutls.org/reference/gnutls-gnutls.html#gnutls-handshake
}while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
ONION_DEBUG("gnutls_handshake() loop out\n");
and build onion with cmake -DCMAKE_BUILD_TYPE=Debug ../
. The below is what I get from log after my instance gets stuck:
[45376E00] [2023-02-04 09:36:56] [DEBUG https.c:228] gnutls_handshake()'ed, ret=-28, strerror=Resource temporarily unavailable, try again.
[45376E00] [2023-02-04 09:36:56] [DEBUG https.c:226] gnutls_handshake()'ing
[45376E00] [2023-02-04 09:42:07] [DEBUG https.c:228] gnutls_handshake()'ed, ret=-28, strerror=Resource temporarily unavailable, try again.
[45376E00] [2023-02-04 09:42:07] [DEBUG https.c:226] gnutls_handshake()'ing
[45376E00] [2023-02-04 09:47:18] [DEBUG https.c:228] gnutls_handshake()'ed, ret=-28, strerror=Resource temporarily unavailable, try again.
[45376E00] [2023-02-04 09:47:18] [DEBUG https.c:226] gnutls_handshake()'ing
[45376E00] [2023-02-04 09:52:30] [DEBUG https.c:228] gnutls_handshake()'ed, ret=-28, strerror=Resource temporarily unavailable, try again.
[45376E00] [2023-02-04 09:52:30] [DEBUG https.c:226] gnutls_handshake()'ing
[45376E00] [2023-02-04 09:57:41] [DEBUG https.c:228] gnutls_handshake()'ed, ret=-28, strerror=Resource temporarily unavailable, try again.
[45376E00] [2023-02-04 09:57:41] [DEBUG https.c:226] gnutls_handshake()'ing
[45376E00] [2023-02-04 10:02:52] [DEBUG https.c:228] gnutls_handshake()'ed, ret=-28, strerror=Resource temporarily unavailable, try again.
[45376E00] [2023-02-04 10:02:52] [DEBUG https.c:226] gnutls_handshake()'ing
[45376E00] [2023-02-04 10:08:04] [DEBUG https.c:228] gnutls_handshake()'ed, ret=-28, strerror=Resource temporarily unavailable, try again.
I am also aware that gnutls's doc on gnutls-handshake() does say that "[o]n these non-fatal errors call this function again, until it returns 0" so I am not sure if this is something Onion can fix.
I am now trying the following, see if it can "solve" the issue (could take weeks to get result):
do{
ONION_DEBUG("gnutls_handshake()'ing\n");
ret = gnutls_handshake (session);
ONION_DEBUG("gnutls_handshake()'ed, ret=%d, strerror=%s\n", ret,gnutls_strerror (ret));
if (ret == -28) {
break;
}
// https://gnutls.org/reference/gnutls-gnutls.html#gnutls-handshake
}while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
Any idea on this?