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: Support HTTP2 Goaway Frame callback for curl multi
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Cao Duc Quan via curl-library <curl-library_at_lists.haxx.se>
Date: Fri, 5 Jan 2024 08:28:19 -0800
Thanks Daniel and Ray for the quick response. My use-case is similar to
https://github.com/curl/curl/issues/4839 where I created a library like a
HTTP2 transport for upper application to send HTTP requests. We have a
logic like this:
1. Open a new HTTP2 connection by creating an HTTP GET to an url path. I
created a CURLM object and added the easy handle for HTTP GET Request to it.
2. Next HTTP request will be sent in the HTTP2 connection created by step
1. I created a new easy handle for this request and added it to
CURLM object created in step 1.
3. After a few hours or less, the connection at step 1 will be closed by
server side (due to idle timeout or TTL). The server will send a GOAWAY
frame to start Graceful shutdown before explicitly closing it after 60s so
that both Client and Server could finish their in-flight transferring.
4. My library needs to detect the connection is closed and reopen a new one
(step 1).
So I have a problem at step 2:
- If the connection created by step 1 received a GOAWAY frame, cURL will
open a new HTTP2 to send the next HTTP request. The new HTTP2 request will
fail because there is some logic check at server side to ensure only
connection created by step 1 is allowed. I believe this is odd checking but
that is the logic from the server side and I could not change it.
Currently, my library hooks to CURLOPT_CLOSESOCKETFUNCTION to detect when
the connection is closed but it is quite late (after Graceful shutdown
window expired). So I seek a hook in the GOAWAY frame to signal my
application so I could proactively create a new HTTP2 connection.
For example, what happens when curl stops the transfer (successfully)
> before the GOAWAY is read?
I believe this is not the case in my application. We used HTTP2 as a
long-live single persistence connection so the GOAWAY will be sent before
closing the connection (assume no network failure here).
Also, to complicate matters, GOAWAY also exists for QUIC/h3.
Can we have this option specific to HTTP2 to reduce blast radius? I learnt
that we have some options like UPKEEP to send ping frames in HTTP2 (not
correctly but seems only HTTP2 support it), could we add a similar option
to GOAWAY?
On Fri, Jan 5, 2024 at 12:10 AM Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Thu, 4 Jan 2024, Cao Duc Quan via curl-library wrote:
>
> > I am working on a small project where I need a callback from CURM when
> it
> > receives the GOAWAY frame. I prepared a patch as follows and could get
> the
> > callback for GOAWAY
>
> Please explain with more words why you need this and what it is for. I'm
> asking because this is a frame that it feels fragile to build
> infrastructure
> around. For example, what happens when curl stops the transfer
> (successfully)
> before the GOAWAY is read?
>
> Also, to complicate matters, GOAWAY also exists for QUIC/h3.
>
> --
>
> / daniel.haxx.se
> | Commercial curl support up to 24x7 is available!
> | Private help, bug fixes, support, ports, new features
> | https://curl.se/support.html
>
Date: Fri, 5 Jan 2024 08:28:19 -0800
Thanks Daniel and Ray for the quick response. My use-case is similar to
https://github.com/curl/curl/issues/4839 where I created a library like a
HTTP2 transport for upper application to send HTTP requests. We have a
logic like this:
1. Open a new HTTP2 connection by creating an HTTP GET to an url path. I
created a CURLM object and added the easy handle for HTTP GET Request to it.
2. Next HTTP request will be sent in the HTTP2 connection created by step
1. I created a new easy handle for this request and added it to
CURLM object created in step 1.
3. After a few hours or less, the connection at step 1 will be closed by
server side (due to idle timeout or TTL). The server will send a GOAWAY
frame to start Graceful shutdown before explicitly closing it after 60s so
that both Client and Server could finish their in-flight transferring.
4. My library needs to detect the connection is closed and reopen a new one
(step 1).
So I have a problem at step 2:
- If the connection created by step 1 received a GOAWAY frame, cURL will
open a new HTTP2 to send the next HTTP request. The new HTTP2 request will
fail because there is some logic check at server side to ensure only
connection created by step 1 is allowed. I believe this is odd checking but
that is the logic from the server side and I could not change it.
Currently, my library hooks to CURLOPT_CLOSESOCKETFUNCTION to detect when
the connection is closed but it is quite late (after Graceful shutdown
window expired). So I seek a hook in the GOAWAY frame to signal my
application so I could proactively create a new HTTP2 connection.
For example, what happens when curl stops the transfer (successfully)
> before the GOAWAY is read?
I believe this is not the case in my application. We used HTTP2 as a
long-live single persistence connection so the GOAWAY will be sent before
closing the connection (assume no network failure here).
Also, to complicate matters, GOAWAY also exists for QUIC/h3.
Can we have this option specific to HTTP2 to reduce blast radius? I learnt
that we have some options like UPKEEP to send ping frames in HTTP2 (not
correctly but seems only HTTP2 support it), could we add a similar option
to GOAWAY?
On Fri, Jan 5, 2024 at 12:10 AM Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Thu, 4 Jan 2024, Cao Duc Quan via curl-library wrote:
>
> > I am working on a small project where I need a callback from CURM when
> it
> > receives the GOAWAY frame. I prepared a patch as follows and could get
> the
> > callback for GOAWAY
>
> Please explain with more words why you need this and what it is for. I'm
> asking because this is a frame that it feels fragile to build
> infrastructure
> around. For example, what happens when curl stops the transfer
> (successfully)
> before the GOAWAY is read?
>
> Also, to complicate matters, GOAWAY also exists for QUIC/h3.
>
> --
>
> / daniel.haxx.se
> | Commercial curl support up to 24x7 is available!
> | Private help, bug fixes, support, ports, new features
> | https://curl.se/support.html
>
-- -------------------------------- Watson Cao VN: (+84) 0976574864 CA: (+1) 2368658864
-- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.htmlReceived on 2024-01-05