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

The response ended prematurely #826

Closed
satishviswanathan opened this issue May 23, 2024 · 2 comments
Closed

The response ended prematurely #826

satishviswanathan opened this issue May 23, 2024 · 2 comments

Comments

@satishviswanathan
Copy link

Flurl.Http" Version="3.2.4"
Dotnet Version: 7
Source and Destination api has been started using Https and can accept both http1.1 and Http 2.0.

@tmenier - I'm getting this error randomly in production, Hence I do not have a code to reproduce this error.

This error happens when one service is invoking another service it randomly fails with the below server.

"Flurl.Http.FlurlHttpException: Call failed. An error occurred while sending the request:
POST https://amy-service/api/updateorder\\n ---
\u003E System.Net.Http.HttpRequestException: An error occurred while sending the request.\n ---\u003E System.IO.IOException:
The response ended prematurely.\n at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\n
--- End of inner exception stack trace ---\n at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\n
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)\n
at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\n
at System.Net.Http.DecompressionHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\n
at System.Net.Http.HttpClient.\u003CSendAsync\u003Eg__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)\n
at Flurl.Http.FlurlRequest.SendAsync(HttpMethod verb, HttpContent content, CancellationToken cancellationToken, HttpCompletionOption completionOption)\n
--- End of inner exception stack trace ---\n at Flurl.Http.FlurlRequest.HandleExceptionAsync(FlurlCall call, Exception ex, CancellationToken token)\n
at Flurl.Http.FlurlRequest.SendAsync(HttpMethod verb, HttpContent content, CancellationToken cancellationToken, HttpCompletionOption completionOption)\n
at Flurl.Http.FlurlRequest.SendAsync(HttpMethod verb, HttpContent content, CancellationToken cancellationToken, HttpCompletionOption completionOption)\n

Although the destination server can accept Http/2 the protocol chosen is Http 1.1 since we don't have the latest version of Flurl in production env.

Any thoughts what could cause this issue ?

@tmenier
Copy link
Owner

tmenier commented Jun 2, 2024

That error is a symptom of the server rejecting the request for some reason. This isn't a Flurl bug. It sounds like you suspect HTTP version could have something to do with it and I do think you might be right. I haven't tried this, but in 3.x you might be able to change the HTTP version using the BeforeCall event and changing call.HttpRequestMessage.Version.

https://v3.flurl.dev/docs/configuration/#event-handlers
https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httprequestmessage.version

@tmenier tmenier removed the bug label Jun 2, 2024
@satishviswanathan
Copy link
Author

@tmenier Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants