curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Libcurl reports 'Error in the HTTP2 framing layer' (16) for outgoing request.

From: Shikha Sharma via curl-library <curl-library_at_cool.haxx.se>
Date: Thu, 3 Jun 2021 16:58:41 +0200

On 5/27/21 11:28 PM, Daniel Stenberg wrote:
> On Thu, 27 May 2021, Shikha Sharma via curl-library wrote:
>
>> HTTP2 connection with prior knowledge initiated by curl, No TLS.
>> Server sends GoAway frame after processing each request.
>
> I suspect the problem/bug here is that the request that reads the
> trailing GOAWAY isn't properly considered as a "dead connection" to
> get retried on a new connection.
That is indeed the issue as verified by the debug logs.
>
> Have you figured out a way to reproduce this issue against public URL
> with a small code snippet that you can share with us?

I am still working on the URL (http server) against which we can test
it. Will provide it as soon as I have it ready.

Meanwhile, I used a simple http_client to send 2 send requests.

  code is available_at_
https://github.com/SharmaShikha-84/Http2-Client/blob/main/http2_client.c

The debugging trace after reproducing the scenario is available at:

https://github.com/SharmaShikha-84/Http2-Client/blob/main/Error_log.txt

As per the logs below:

* http2_recv: easy 0x7ef890 (stream 0) win 33553522/4294967295
* h2_process_pending_input: All data in connection buffer processed
* http2_recv returns 0, http2_handle_stream_close
* Connection #0 to host 192.168.99.199 left intact
* Found bundle for host 192.168.99.199: 0x7f83f0 [can multiplex]
* 17 bytes stray data read before trying h2 connection
----------------------------------(Goaway received here )
* h2_process_pending_input: All data in connection buffer processed
* h2_process_pending_input: nothing to do in this session
-----------------------------------(Should have been closed here)
* Re-using existing connection! (#0) with host 192.168.99.199
-----------------------------------(Connection reused even after goaway)
* Connected to 192.168.99.199 (192.168.99.199) port 8000 (#0)
* http2_send len=117
* h2 header: :method:GET
* h2 header:
:path:/nnrf-nfm/v1/nf-instances/e219be29-c62c-4710-a8d5-4e48680a6080
* h2 header: :scheme:http
* h2 header: :authority:192.168.99.199:8000
* h2 header: accept:*/*
* http2_send request allowed 0 (easy handle 0x7ef890)
-------------------------------------(Request not allowed anymore still
nghttp2_submit called)
* Using Stream ID: 3 (easy handle 0x7ef890)
* on_stream_close(), REFUSED_STREAM (err 7), stream 3
--------------------------------------( As a result stream is refused )

Proposed solution:

curl -V
curl 7.74.0 (x86_64-redhat-linux-gnu) libcurl/7.74.0 NSS/3.44 zlib/1.2.7
libpsl/0.7.0 (+libicu/50.1.2) libssh2/1.8.0 nghttp2/1.39.1
Release-Date: 2020-12-09
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps
mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos
Largefile libz Metalink NTLM NTLM_WB PSL SPNEGO SSL UnixSocketsution:

--- http2_modified.c  2021-06-03 16:44:31.097874213 +0200
+++ http2.c    2021-06-03 16:46:30.203469531 +0200
_at__at_ -199,7 +199,11 _at__at_
                (int)nread);
          httpc->nread_inbuf = 0;
          httpc->inbuflen = nread;
-        (void)h2_process_pending_input(conn, httpc, &result);
+        if (h2_process_pending_input(conn, httpc, &result) < 0)
+        {
+            /* connection can be closed */
+            dead = TRUE;
+        }
        }
        else
          /* the read failed so let's say this is dead anyway */


Trace after fix:

https://github.com/SharmaShikha-84/Http2-Client/blob/main/Trace_after_fix

Regards,

Shikha

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html
Received on 2021-06-03