-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Triggering IConnectionLifetimeNotificationFeature on GoAway #43431
Conversation
Thanks for your PR, @ladeak. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think YARP could take advantage of this since it can't (and wouldn't want to) proxy the GoAway to the destination server. YARP would be limited to canceling individual requests/streams which would not be graceful. |
Is this for the situation where a client has sent a GOAWAY, but the socket is still alive, and it prevents Kestrel from shutting down without hitting a timeout? I haven't heard anyone bring that up as a gRPC issue. |
If you come to the conclusion that maybe then this change should be reconsidered, I was aware that the conversation for the issue still had this open question. Even in this case, I don't mind spending the time on the implementation. |
cb7d700
to
f8deebe
Compare
1bdf507
to
4bf0314
Compare
@halter73 I am a little puzzled: I have prepared a test as suggested with socketsHttpHandler.PooledConnectionIdleTimeout but I don't seem to receive any GoAway frame. I am reviewing Http3Connection, Http3RequestStream and HttpConnectionPool but I am afraid I did not find the place where the GoAway frame would be sent on idle connections. Could you help me point me to the right direction, so that I can better understand this case and prepare the test? |
@ladeak Sorry for telling you to go ahead with this and then asking for these tests before more closely looking at the client behavior. I probably shouldn't have even marked it up for grabs until I had done that. I think you're right that SocketsHttpHandler simply never initiates a graceful close of the connection with a GOAWAY frame. The client is allowed to gracefully close an HTTP/3 connection with a GOAWAY frame according to the HTTP/3 spec, but it certainly isn't required to. The server "SHOULD" send such a frame, but it's not even required to. In the HTTP/2 spec, I think the "SHOULD" goes both for both the server and the client. @dotnet/ncl Can someone tell me off the top of their head if SocketsHttpHandler ever initiates a graceful GOAWAY for either HTTP/2 or HTTP/3 connections. If so, under what circumstances? Idle timeouts? Disposing the HttpClient with in flight requests? |
As far as I know, |
Cool. I still don't see the harm in doing this. The spec allows it, and we have the tests where we manually send the GOAWAY frames. I see no reason not to fire a |
Is it possible/expected that the interface may be notified multiple times for the same connection? |
No, but it's backed by a CancellationToken, so we should be good. aspnetcore/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelConnection.cs Lines 150 to 161 in c7a4ec8
|
I think the non-test changes are fine. Is an interop test for HTTP/3 necessary? Because we haven't built a fully-fledged HTTP/3 client for our tests you've needed to hack in parsing H3 frames and QPack in the interop tests. I think the in-memory functional test (we probably should at some point invest in making the in-memory methods support real HTTP/3 over QUIC, but that's a whole other thing) |
I agree with @JamesNK. I think |
4bf0314
to
be4d807
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
… GoAway On GoAway frames triggering `IConnectionLifetimeNotificationFeature`'s cancellation for gRPC and SignalR to initiate teardown of long running requests. ## Description For Kestrel h2 and h3 triggering `IConnectionLifetimeNotificationFeature` feature's *RequestClose()* method on GoAway frames, so that frameworks like SignalR or gRPC may proactively start closing long running request. h3 control stream (which is the only stream that handles GoAway) also calls *StopProcessingNextRequest()* method otherwise `HttpConnection` (subscribed to `IConnectionLifetimeNotificationFeature`) would send GoAway's from server. h2 already does the same. Adding new tests: `Http3InMemory` now implements *RequestClose()* method and `Http2TestBase` mimics sharing the same feature collection on ConnectionFeatures and by the Connection's Features properties. Fixes dotnet#42057
be4d807
to
948cb5b
Compare
Could someone trigger a new build here? cc. @halter73 |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Triggering Connection Lifetime Notification Feature's cancellation on GoAway
On GoAway frames triggering
IConnectionLifetimeNotificationFeature
's cancellation for gRPC and SignalR to initiate teardown of long running requests.Description
For Kestrel h2 and h3 triggering
IConnectionLifetimeNotificationFeature
feature's RequestClose() method on GoAway frames, so that frameworks like SignalR or gRPC may proactively start closing long running request.h3 control stream (which is the only stream that handles GoAway) also calls StopProcessingNextRequest() method otherwise
HttpConnection
(subscribed toIConnectionLifetimeNotificationFeature
) would send GoAway's from server. h2 already does the same.Adding new tests:
Http3InMemory
now implements RequestClose() method andHttp2TestBase
mimics sharing the same feature collection on ConnectionFeatures and by the Connection's Features properties.Fixes #42057