From 436b97cc809a3db1d1a25faedbc64aa97875bae3 Mon Sep 17 00:00:00 2001 From: Natalia Kondratyeva Date: Tue, 15 Mar 2022 01:34:46 +0100 Subject: [PATCH] Set SocketsHttpHandler's default connect timeout to 15s (#66607) * Set default connect timeout to 15s * Fix ConnectTimeout_Default test --- src/libraries/Common/src/System/Net/Http/HttpHandlerDefaults.cs | 2 +- .../tests/FunctionalTests/SocketsHttpHandlerTest.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/Common/src/System/Net/Http/HttpHandlerDefaults.cs b/src/libraries/Common/src/System/Net/Http/HttpHandlerDefaults.cs index 3bf335ec33cea4..98e7dddc1120ca 100644 --- a/src/libraries/Common/src/System/Net/Http/HttpHandlerDefaults.cs +++ b/src/libraries/Common/src/System/Net/Http/HttpHandlerDefaults.cs @@ -27,6 +27,6 @@ internal static partial class HttpHandlerDefaults public static readonly TimeSpan DefaultPooledConnectionLifetime = Timeout.InfiniteTimeSpan; public static readonly TimeSpan DefaultPooledConnectionIdleTimeout = TimeSpan.FromMinutes(1); public static readonly TimeSpan DefaultExpect100ContinueTimeout = TimeSpan.FromSeconds(1); - public static readonly TimeSpan DefaultConnectTimeout = Timeout.InfiniteTimeSpan; + public static readonly TimeSpan DefaultConnectTimeout = TimeSpan.FromSeconds(15); } } diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs index 7a0b5de4d52050..78c6f36c7a00cb 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs @@ -1054,7 +1054,7 @@ public void ConnectTimeout_Default() { using (var handler = new SocketsHttpHandler()) { - Assert.Equal(Timeout.InfiniteTimeSpan, handler.ConnectTimeout); + Assert.Equal(TimeSpan.FromSeconds(15), handler.ConnectTimeout); } }