Skip to content

Commit bd289ed

Browse files
authored
Set the default ConnectTimeout to a finite value (#1991)
1 parent 2268912 commit bd289ed

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

docs/docfx/articles/direct-forwarding.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public void Configure(IApplicationBuilder app, IHttpForwarder forwarder)
5252
AllowAutoRedirect = false,
5353
AutomaticDecompression = DecompressionMethods.None,
5454
UseCookies = false,
55-
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current)
55+
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
56+
ConnectTimeout = TimeSpan.FromSeconds(15),
5657
});
5758
var transformer = new CustomTransformer(); // or HttpTransformer.Default;
5859
var requestConfig = new ForwarderRequestConfig { ActivityTimeout = TimeSpan.FromSeconds(100) };

docs/docfx/articles/http-client-config.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ new SocketsHttpHandler
209209
AllowAutoRedirect = false,
210210
AutomaticDecompression = DecompressionMethods.None,
211211
UseCookies = false,
212-
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current)
212+
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
213+
ConnectTimeout = TimeSpan.FromSeconds(15),
213214
};
214215
```
215216

samples/ReverseProxy.Direct.Sample/Startup.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public void Configure(IApplicationBuilder app, IHttpForwarder forwarder)
4141
AutomaticDecompression = DecompressionMethods.None,
4242
UseCookies = false,
4343
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
44+
ConnectTimeout = TimeSpan.FromSeconds(15),
4445
});
4546

4647
// Setup our own request transform class

src/ReverseProxy/Forwarder/ForwarderHttpClientFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public HttpMessageInvoker CreateClient(ForwarderHttpClientContext context)
4848
AutomaticDecompression = DecompressionMethods.None,
4949
UseCookies = false,
5050
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
51+
ConnectTimeout = TimeSpan.FromSeconds(15),
5152

5253
// NOTE: MaxResponseHeadersLength = 64, which means up to 64 KB of headers are allowed by default as of .NET Core 3.1.
5354
};

testassets/ReverseProxy.Direct/Startup.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
using System;
5+
using System.Diagnostics;
56
using System.Net;
67
using System.Net.Http;
78
using System.Threading.Tasks;
@@ -37,7 +38,9 @@ public void Configure(IApplicationBuilder app)
3738
UseProxy = false,
3839
AllowAutoRedirect = false,
3940
AutomaticDecompression = DecompressionMethods.None,
40-
UseCookies = false
41+
UseCookies = false,
42+
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
43+
ConnectTimeout = TimeSpan.FromSeconds(15),
4144
});
4245

4346
var transformBuilder = app.ApplicationServices.GetRequiredService<ITransformBuilder>();

0 commit comments

Comments
 (0)