question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Customizing HTTP/2 abort response

See original GitHub issue

In gRPC there is the concept of a deadline. The deadline is sent by the client to the server with a gRPC call in a header. It is the client saying to the server “you have X seconds to finish this call, after-which give up”.

  • If the server finished the call in less than X sends then the response completes as usual.
  • If the server exceeds the X seconds then it immediately finishes the HTTP/2 response, sending a RST_STREAM. The user’s gRPC method code will likely still be executing after this. If they are good then it will be using a cancellation token, and they stop whatever they’re doing quickly. But they might not, and continue doing stuff after the response is complete. This is fine. It is also fine if an error eventually gets thrown because they tried to do an HTTP thing.

Today the gRPC server is finishing the connection when the deadline is hit by calling HttpContext.Abort(). This immediately sends RST_STREAM with an INTERNAL_ERROR error code. The request delegate with the user’s code is still running. Using Abort is not ideal, but its response seems to be acceptable to the various gRPC clients of the world.

Today that response on Abort looks very hard-coded in Http2Stream:

protected override void ApplicationAbort()
{
    var abortReason = new ConnectionAbortedException(CoreStrings.ConnectionAbortedByApplication);
    ResetAndAbort(abortReason, Http2ErrorCode.INTERNAL_ERROR);
}

I think the current abort behavior is fine for gRPC to use with deadline, the one thing that could be improved is the abort response over HTTP/2. We’re sending INTERNAL_ERROR, and no status trailers. Another gRPC implementation I looked at immediately ends the response, but it sends RST_STREAM (NO_ERROR), along with some HTTP/2 trailing headers.

It would be nice to have a hook in ASP.NET Core to modify the response when an HTTP/2 abort occurs, such as changing the Http2ErrorCode used with RST_STREAM, or appending trailers.

Thoughts around the area? Or alternatives?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:43 (43 by maintainers)

github_iconTop GitHub Comments

1reaction
Tratchercommented, Jun 18, 2019

I want to add the same features to TestServer quick.

1reaction
Tratchercommented, Jun 16, 2019

HTTP/3 doesn’t have Reset itself, that’s a QUIC feature. I could just call it IResetFeature.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Detect aborted HTTP2 requests in Spring Boot backend ...
AFAIK (but I might be wrong on this), when using HTTP2, aborting the request sends ... ConditionalContentCachingResponseWrapper) response).
Read more >
Introduction to HTTP/2 - web.dev
HTTP/2 (or h2) is a binary protocol that brings push, multiplexing streams ... That said, unless you are implementing a web server (or...
Read more >
HTTP/2: The Sequel is Always Worse
The answer is HTTP/2 downgrading. HTTP/2 Desync Attacks. Request Smuggling via HTTP/2 Downgrades. HTTP/2 downgrading is when a front-end server ...
Read more >
Advanced HTTP networking - Apollo GraphQL Docs
Finally, the HttpLink sends the modified request. Customizing response logic. You can use Apollo Link to customize Apollo Client's behavior whenever it receives ......
Read more >
mod_http2 - Apache HTTP Server Version 2.4
This module can be configured to provide HTTP/2 related information as additional environment variables to the SSI and CGI namespace, as well as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found