Skip to content
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

HttpIOException when establishing connection, unobserved task exception #102772

Closed
mattchidley opened this issue May 28, 2024 · 3 comments · Fixed by #102960
Closed

HttpIOException when establishing connection, unobserved task exception #102772

mattchidley opened this issue May 28, 2024 · 3 comments · Fixed by #102960
Labels
area-System.Net.Http bug help wanted [up-for-grabs] Good issue for external contributors
Milestone

Comments

@mattchidley
Copy link

Describe the bug

Ever since 8.0.3 we've been seeing UnobservedTaskException: System.Net.Http.HttpIOException: An HTTP/2 connection could not be established because the server did not complete the HTTP/2 handshake. (InvalidResponse)

We have not seen this before 8.0.3 with our current environment.

We are curious whether there has been a change in the framework with how the handshake handles an unexpected connection termination with the host? These errors coincide with service disruption on the host.

Repro

While I can't provide a working sample because I think timing and load plays a key factor, our belief is that during client -> server connection negotiation the webserver is shutdown.

Exceptions (if any)

UnobservedTaskException: System.Net.Http.HttpIOException: An HTTP/2 connection could not be established because the server did not complete the HTTP/2 handshake. (InvalidResponse)

Further technical details

We have observed this on .net 8.0.3, 8.04, and 8.0.5, we do not see this on 8.0.2 or 7.0

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label May 28, 2024
@baronfel baronfel transferred this issue from dotnet/sdk May 28, 2024
@MihaZupan
Copy link
Member

Can you share the stack trace of those unobserved exceptions?

@ManickaP ManickaP added the needs-author-action An issue or pull request that requires more info or actions from the author. label May 29, 2024
@mattchidley
Copy link
Author

System.Net.Http.HttpIOException: The response ended prematurely while waiting for the next frame from the server. (ResponseEnded)
File "Http2Connection.cs", line 466, in ValueTask Http2Connection.ReadFrameAsync(bool initialFrame)+ThrowMissingFrame()
throw new HttpIOException(HttpRequestError.ResponseEnded, SR.net_http_invalid_response_missing_frame);
File "Http2Connection.cs", line 417, in async ValueTask Http2Connection.ReadFrameAsync(bool initialFrame)
ThrowMissingFrame();
File "Http2Connection.cs", line 477, in async Task Http2Connection.ProcessIncomingFramesAsync()
frameHeader = await ReadFrameAsync(initialFrame: true).ConfigureAwait(false);

System.Net.Http.HttpIOException: An HTTP/2 connection could not be established because the server did not complete the HTTP/2 handshake. (InvalidResponse)
System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.

@dotnet-policy-service dotnet-policy-service bot removed the needs-author-action An issue or pull request that requires more info or actions from the author. label May 29, 2024
@MihaZupan MihaZupan added the bug label May 29, 2024
@MihaZupan
Copy link
Member

We're creating a new exception here to signal the InitialSettingsReceived TCS, which may never get observed.

InitialSettingsReceived.TrySetException(new HttpIOException(HttpRequestError.InvalidResponse, SR.net_http_http2_connection_not_established, e));

This code has been there in a similar form since 8.0 preview 1 (#80066), so not an 8.0 servicing regression.
It's a bug we should fix (same as other places where we might throw unobserved exceptions), but should be functionally benign.

@MihaZupan MihaZupan removed the untriaged New issue has not been triaged by the area owner label May 29, 2024
@MihaZupan MihaZupan added this to the Future milestone May 29, 2024
@MihaZupan MihaZupan added the help wanted [up-for-grabs] Good issue for external contributors label May 29, 2024
@MihaZupan MihaZupan modified the milestones: Future, 9.0.0 Jun 11, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Http bug help wanted [up-for-grabs] Good issue for external contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants