-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
Description
Type of issue
Missing information
Description
ArgumentOutOfRangeException
The timeout specified is less than or equal to zero and is not InfiniteTimeSpan.
From the source code, it actually throws when you put in value greater than about 24 days (int.MaxValue
ms) too:
private static readonly TimeSpan s_maxTimeout = TimeSpan.FromMilliseconds(int.MaxValue);
// ...
public TimeSpan Timeout
{
get => _timeout;
set
{
if (value != s_infiniteTimeout)
{
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(value, TimeSpan.Zero);
ArgumentOutOfRangeException.ThrowIfGreaterThan(value, s_maxTimeout);
}
CheckDisposedOrStarted();
_timeout = value;
}
}
I encountered this issue when trying to set it to TimeSpan.MaxValue
:
System.ArgumentOutOfRangeException: value ('10675199.02:48:05.4775807') must be less than or equal to '24.20:31:23.6470000'. (Parameter 'value')
Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.timeout?view=net-9.0
Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Net.Http/HttpClient.xml
Document Version Independent Id
199a48e3-16ed-9fe0-8957-f14f37a17acd