应用程序网关默认运行状况探测 ECONNRESET 异常

应用程序网关默认运行状况探测 ECONNRESET 异常

我们在 Azure VM 上的 Web 应用程序前面配置了一个应用程序网关。我们经常看到 ECONNRESET 异常发生,这些异常似乎是由于默认健康探测而产生的。我每隔 30 秒就会看到几个对 127.0.0.1 的请求。根据以下输出,这些请求中的一个会相当频繁地(过去 24 小时内超过 20 个实例)导致 ECONNRESET 异常:

17:10:35 [Information] () "Request starting HTTP/1.1 GET http://127.0.0.1/  "

17:10:35 [Information] () {"Connection":["Keep-Alive"],"Host":["127.0.0.1"],"Max-Forwards":["10"]}

17:10:35 [Information] () Executing action method "HonestyBoxWeb.Controllers.HomeController.Index (HonestyBoxWeb)" with arguments (null) - ModelState is Valid

17:10:35 [Information] () Executing ViewResult, running view at path "/Views/Home/Index.cshtml".

17:10:35 [Information] () Executed action "HonestyBoxWeb.Controllers.HomeController.Index (HonestyBoxWeb)" in 2.8666ms

17:10:35 [Information] () "Request finished in 5.2758ms 200 text/html; charset=utf-8"

17:10:35 [Information] () Connection id ""0HLCE7PIFCIGH"" request processing ended abnormally.
System.IO.IOException: Error -104 ECONNRESET connection reset by peer ---> Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvException: Error -104 ECONNRESET connection reset by peer
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvOutputConsumer.<WriteOutputAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvConnection.<Start>d__26.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.PipeCompletion.ThrowFailed()
   at Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.Pipe.GetResult(ReadResult& result)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.Pipe.Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.IReadableBufferAwaiter.GetResult()
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame`1.<ProcessRequestsAsync>d__2.MoveNext()

因此,健康检查似乎正在发布请求,然后重置连接。我的理解正确吗?有什么方法可以解决这个问题吗?

答案1

这是 Kestrel 服务器中的一个问题,已在 dotnet core 2.1 版本中得到解决。

参考:https://github.com/aspnet/KestrelHttpServer/issues/2540

相关内容