http请求端口占用异常
2021-04-29 07:27
标签:tpm 思路 ensure stat http result sre ons cti 解决思路: 1. ESTABLISHED 过多,使用static解决 2.方案1导致ESTABLISHED 控制住,但是CLOSE_WAIT太多,使用IHttpClientFactory解决 http请求端口占用异常 标签:tpm 思路 ensure stat http result sre ons cti 原文地址:https://www.cnblogs.com/panpanwelcome/p/12203076.html static HttpClientHandler StaticHttpClientHandler = new HttpClientHandler
{
AllowAutoRedirect = true,
Proxy = new System.Net.WebProxy(ConfigHelper.FacebookProxyHostUrl)
};
static HttpClient StaticHttpClient = new HttpClient(StaticHttpClientHandler, false)
{
Timeout = TimeSpan.FromSeconds(10)
};
[HttpGet]
[Route(nameof(TestProxy))]
public async Task
//Startup.cs中的public void ConfigureServices(IServiceCollection services)
services.AddHttpClient();
services.AddHttpClient("configured-proxy-handler")
.ConfigurePrimaryHttpMessageHandler(() =>
{
return new HttpClientHandler()
{
AllowAutoRedirect = true,
Proxy = new System.Net.WebProxy(ConfigHelper.FacebookProxyHostUrl)
};
});
//使用
private readonly IHttpClientFactory _httpClientFactory;
public OpsController(IHttpClientFactory httpClientFactory)
{
_httpClientFactory = httpClientFactory;
}
[HttpGet]
[Route(nameof(TestProxy3))]
public async Task