-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add API to get RST_STREAM value from HTTP exceptions #43239
Comments
Tagging subscribers to this area: @dotnet/ncl |
I agree that we should expose this value. There's a similar issue with error codes from GOAWAY -- this is similar to RST_STREAM, except it affects the whole connection and kills all streams. As part of exposing the RST_STREAM error code, we should also consider exposing the GOAWAY error code if/when appropriate. We should also try to do this in such a way that it works for HTTP3 as well, since there is a similar error code capability in HTTP3. Not sure to what extent the error codes are aligned, though... |
HTTP/3 error codes are distinct https://quicwg.org/base-drafts/draft-ietf-quic-http.html#section-11.2.3 |
Of course they are :( And they can be 62 bits long, too. I guess this argues for having something like |
It looks like distinct ranges for each protocol. Http2: <255 |
As discussed earlier, we won't be able to make this in 6.0. Moving to Future. |
Behold the hack I added to gRPC: https://github.com/grpc/grpc-dotnet/blob/ac3b3f4309b29b0c4fb9048da961e8c054ee955a/src/Grpc.Net.Client/Internal/GrpcProtocolHelpers.cs#L422-L561 😄 It's not good but it works. Obviously, it would be great to improve with a real API. |
I also agree that we should create a unified proposal that covers RST_STREAM, GOAWAY, and the HTTP/3 cases. What makes this tricky is the way the exception/error information is nested today:
One possible solution is to expose the exception types If simplification is not possible, we can create a shortcut as a separate property on public class HttpRequestException {
// Http2StreamException, Http2ConnectionException or QuicStreamAbortedException:
public Exception? ProtocolException { get; }
} A different approach would be to expose protocol error code right on A possible API: public class HttpRequestException {
long? ProtocolErrorCode { get; }
ProtocolErrorSource? ProtocolErrorSource { get; }
}
public enum ProtocolErrorSource {
Http2Stream,
Http2Connection,
QuicStream
} @dotnet/ncl thoughts? |
I don't think we need a way to distinguish. When I experimented with how to get error codes, which resulted in the exception message parsing code I linked to, all the thrown errors I found were either When is tldr |
@JamesNK since your |
I care about those as well. Those scenarios never happened in my tests so I never needed to check for Http2ConnectionException. 10 points to SocketsHttpHandler and ASP.NET Core for not violating the HTTP/2 protocol 😄 |
@karelz This was moved from 6.0 to future last year, but it was never added to the 7.0 milestone. Should it be? |
@JamesNK here it is in 7.0 😄 @dotnet/ncl can we think of cases when a user would need to see which of the many possible scenarios has resulted in |
@JamesNK sorry, that was an oversight on our side. Thanks @antonfirsov for fixing it! |
Are there places where a protocol error occurred but HttpRequestExveption isn’t the exception thrown? |
Here is at least one case where In this situation, |
Well, makes it trickier, opening up up a bunch of options:
Edit:
A lot depends on the answer on my question in #62228 (comment) |
Long story short, it looks like we can get away with a simple API addition for this particular issue: public class HttpRequestException {
long? ProtocolErrorCode { get; }
} We can extend this with more error details later if we want. We can utilize it to solve #62228. |
Team discussion: |
This is also related to decision whether to derive This line of thinking depends on the decision we'll make in #56954. @rzikm, could you please take this into account when you're thinking about QUIC exceptions? Either way, as a fallback we can always do what #43239 (comment) above ^ suggests. |
Closing this in favor of #70684 |
Part of User Story: dotnet/core#5493
Background and Motivation
gRPC specifies that RST_STREAM error codes are mapped to gRPC error codes - https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#errors
I believe that today the RST_STREAM value is only exposed in exception message descriptions. The only way to get this value is to parse exception messages, which is pretty awful for the usual reasons.
There should be an exception property with the RST_STREAM error code so it can be used programmatically.
Proposed API
Make this value publicly accessible:
runtime/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2ProtocolException.cs
Line 28 in faf91e0
I don't feel strongly that it needs to be an enum.
public int ProtocolError { get; }
would also be fine.The text was updated successfully, but these errors were encountered: