-
Notifications
You must be signed in to change notification settings - Fork 763
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
HttpClient.Timeout overrides the TotalRequestTimeout when using AddStandardResilienceHandler #4770
Comments
Why is it better to use Polly's timeout policy implementation over built in HttpClient timeout? There is also a second possible solution to just make polly set the HttpClient.Timeout to the right value. |
Few reasons why this is beneficial:
This would lead to race conditions between Polly's timeout and HttpClient's timeout. Sometimes the timeout would be triggered by HttpClient, other times by Polly. |
This has a fix for dotnet/extensions#4770 which causes our EndToEnd tests to timeout if a service doesn't start in 100 seconds.
This has a fix for dotnet/extensions#4770 which causes our EndToEnd tests to timeout if a service doesn't start in 100 seconds.
Disables HttpClient Timeout for standard resilience and hending handlers
* Fixes #4924 and #4770 Disables HttpClient Timeout for standard resilience and hending handlers * Fixes #4924 Adds a note mentioning requirements on the Grpc.Net.ClientFactory version to avoid issues with the M.E.Http.Resilience package * Fixes #4924 Added a target that notifies users that they use a version of the Grpc.Net.ClientFactory package that might cause the #4924 issue * Fixes #4924 Revert changes to the Directory.Build.targets * Fixes #4924 Adds a target that checks whether M.E.Http.Resilience package is used together with Grpc.Net.ClientFactory 2.64.0 or later. If not the target warns a user. * Fixes #4924 Adds a Known issues section to the doc describing the issue with Grpc.Net.ClientFactory * Fixes #4924 * Moves the contents of the .props file into the .targets file * For net462 we now import the contents of the .targets file instead of setting it as a CDATA value in the .csproj file * Fixes #4924 Replaces the name of the project file with the MSBuildProjectName variable * Fixes #4924 * Add conditions to pack buildTransitive .targets for net462 only when net462 is included as a target framework * Changed the documentation link to the learn.microsoft.com site * Fixes #4924 * Applies editorial changes to the Known issues section * Fixes #4924 * Changes the level of the compatibility log messages from Error to Warning * Updates the logic of copying buildTransitive files * Removed extra spaces * Applied suggestions to update the documentation * Removed locale from the URL
Description
The
HttpClient.Timeout
interferes with theTotalRequestTimeout
when using HttpClient with standard pipeline. IfHttpClient.Timeout
is less thanTotalRequestTimeout
, then theTotalRequestTimeout
is ignored.This causes mis-alignment and unexpected behavior for anyone setting the
TotalRequestTimeout
to a value greater than 100 seconds, which is the default forHttpClient.Timeout
.Calling
AddStandardResilienceHandler
should disable theHttpClient.Timeout
by setting the value toTimeout.InfiniteTimeSpan
, because the overall timeout is already enforced by standard pipeline. This also saves some allocations due to HttpClient not needing to createCancellationTokenSource
.Reproduction Steps
Execute this code:
This should be successful. Instead, the
TaskCancelledException
is thrown.Expected behavior
Above example should not throw exception.
Actual behavior
Above example throws
TaskCancelledException
.Regression?
No response
Known Workarounds
Manually disable HttpClient timeout:
Configuration
.NET SDK:
Version: 8.0.100
Commit: 57efcf1350
Workload version: 8.0.100-manifests.6a1e483a
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.100\
Other information
No response
The text was updated successfully, but these errors were encountered: