Skip to content

Commit

Permalink
Set the default ConnectTimeout to a finite value (#1991)
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan authored Jan 11, 2023
1 parent 2268912 commit bd289ed
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/docfx/articles/direct-forwarding.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public void Configure(IApplicationBuilder app, IHttpForwarder forwarder)
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false,
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current)
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
ConnectTimeout = TimeSpan.FromSeconds(15),
});
var transformer = new CustomTransformer(); // or HttpTransformer.Default;
var requestConfig = new ForwarderRequestConfig { ActivityTimeout = TimeSpan.FromSeconds(100) };
Expand Down
3 changes: 2 additions & 1 deletion docs/docfx/articles/http-client-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ new SocketsHttpHandler
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false,
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current)
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
ConnectTimeout = TimeSpan.FromSeconds(15),
};
```

Expand Down
1 change: 1 addition & 0 deletions samples/ReverseProxy.Direct.Sample/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public void Configure(IApplicationBuilder app, IHttpForwarder forwarder)
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false,
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
ConnectTimeout = TimeSpan.FromSeconds(15),
});

// Setup our own request transform class
Expand Down
1 change: 1 addition & 0 deletions src/ReverseProxy/Forwarder/ForwarderHttpClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public HttpMessageInvoker CreateClient(ForwarderHttpClientContext context)
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false,
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
ConnectTimeout = TimeSpan.FromSeconds(15),

// NOTE: MaxResponseHeadersLength = 64, which means up to 64 KB of headers are allowed by default as of .NET Core 3.1.
};
Expand Down
5 changes: 4 additions & 1 deletion testassets/ReverseProxy.Direct/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System;
using System.Diagnostics;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
Expand Down Expand Up @@ -37,7 +38,9 @@ public void Configure(IApplicationBuilder app)
UseProxy = false,
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false
UseCookies = false,
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
ConnectTimeout = TimeSpan.FromSeconds(15),
});

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

0 comments on commit bd289ed

Please sign in to comment.