應用程式網關預設運作狀況偵測 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

相關內容