问题描述
使用 .NET Core 3.1 的 WebAPI 应用程序以 HAProxy
作为前端向应用程序发送 POST 调用。应用程序托管在 2 个 Windows 核心服务器上,每天处理大约 50k 次调用。 21 秒后 API 调用间歇性失败。
IHttpClientFactory
已按照以下 Microsoft 文档实施。
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-3.1
客户端抓包显示客户端,服务器端的SYN和ACK成功后发送RST。
异常:
A connection attempt Failed because the connected party did not properly respond after a period of time,or an established connection Failed because the connected host has Failed to respond.
System.Net.sockets.socketException (10060): A connection attempt Failed because the connected party did not properly respond after a period of time,or an established connection Failed because the connected host has Failed to respond.
at System.Net.Http.ConnectHelper.ConnectAsync(String host,Int32 port,CancellationToken cancellationToken)
at System.Net.Http.ConnectHelper.ConnectAsync(String host,CancellationToken cancellationToken)
at System.Net.Http.httpconnectionPool.ConnectAsync(HttpRequestMessage request,Boolean allowHttp2,CancellationToken cancellationToken)
at System.Net.Http.httpconnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request,CancellationToken cancellationToken)
at System.Net.Http.httpconnectionPool.GethttpconnectionAsync(HttpRequestMessage request,CancellationToken cancellationToken)
at System.Net.Http.httpconnectionPool.SendWithRetryAsync(HttpRequestMessage request,Boolean doRequestAuth,CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask,HttpRequestMessage request,CancellationTokenSource cts,Boolean disposeCts)
at SCMdatamartAPI.Elastic.ElasticclientService.IndexElasticDocument(Object json,String indexName)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)