-
Notifications
You must be signed in to change notification settings - Fork 849
Description
Description
I debated if this was a bug or a feature request, but since Aspire sets this by the default (which it should) and then every single HttpClient you create then is forced into those defaults with apparently no way to override them, this becomes a bug because it's both not discoverable with what's happening and the documentation says nothing about this, while simultaneously adding a new resilience handler to a specific client implementation doesn't override it.
Hence, at best, it's a bug in documentation, but more, this is a major blocker, because it's impossible to set anything other than defaults as soon as you opt into this, which I can't imagine was the design intent.
Reproduction Steps
If this is in your project.
builder.Services.ConfigureHttpClientDefaults(http => {
//Turn on resilience by default
http.AddStandardResilienceHandler();
// Turn on service discovery by default
http.UseServiceDiscovery();
});
The timeout on any client that you try and override will be ignored.
This doesn't work.
services.AddHttpClient<IKaiLLamaClient, LLamaKaiLLM>()
.AddStandardResilienceHandler(options => {
options.AttemptTimeout = new HttpTimeoutStrategyOptions {
Timeout = TimeSpan.FromMinutes(5)
};
options.TotalRequestTimeout = new HttpTimeoutStrategyOptions {
Timeout = TimeSpan.FromMinutes(15)
};
options.CircuitBreaker.SamplingDuration = TimeSpan.FromMinutes(10);
});
This doesn't work: (where timeoutPolicy is a polly timeout policy that sets the time out)
builder.Services.AddHttpClient<IOrca2LLamaClient, LLamaOrca2LLM>(client => {
client.Timeout = TimeSpan.FromMinutes(5);
})
.AddPolicyHandler(timeoutPolicy);
I've tried every permutation and combination I can think of, and in all cases, it is ignored.
Expected behavior
You should be able to override the defaults on a specific client and how to do so should be documented clearly.
This should just work:
services.AddHttpClient<IKaiLLamaClient, LLamaKaiLLM>()
.AddStandardResilienceHandler(options => {
options.AttemptTimeout = new HttpTimeoutStrategyOptions {
Timeout = TimeSpan.FromMinutes(5)
};
options.TotalRequestTimeout = new HttpTimeoutStrategyOptions {
Timeout = TimeSpan.FromMinutes(15)
};
options.CircuitBreaker.SamplingDuration = TimeSpan.FromMinutes(10);
});
Or there should be an OverrideResilienceHandler that replaces it for this client or something.
Actual behavior
It appears to just add a new resiliance handler that is suplimental to the other one, so whatever one times out first, kills the client.
Regression?
No response
Known Workarounds
None other than removing all default resiliance handling for http.
Configuration
.NET SDK:
Version: 8.0.100
Commit: 57efcf1350
Workload version: 8.0.100-manifests.71b9f198
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.100\
.NET workloads installed:
Workload version: 8.0.100-manifests.71b9f198
[aspire]
Installation Source: SDK 8.0.100, VS 17.9.34321.82
Manifest Version: 8.0.0-preview.1.23557.2/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.0.0-preview.1.23557.2\WorkloadManifest.json
Install Type: Msi
[maui-windows]
Installation Source: VS 17.8.34330.188
Manifest Version: 8.0.3/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.3\WorkloadManifest.json
Install Type: Msi
[maccatalyst]
Installation Source: VS 17.8.34330.188
Manifest Version: 17.0.8478/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\17.0.8478\WorkloadManifest.json
Install Type: Msi
[ios]
Installation Source: VS 17.8.34330.188
Manifest Version: 17.0.8478/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.0.8478\WorkloadManifest.json
Install Type: Msi
[android]
Installation Source: VS 17.8.34330.188
Manifest Version: 34.0.43/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.43\WorkloadManifest.json
Install Type: Msi
Host:
Version: 8.0.0
Architecture: x64
Commit: 5535e31a71
.NET SDKs installed:
6.0.417 [C:\Program Files\dotnet\sdk]
7.0.404 [C:\Program Files\dotnet\sdk]
8.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
E:\Repos\Atteria\Pltfrmd\services\global.json
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Other information
No response