在调查Azure App Service .NET Core 2.1 ArgumentOutOfRangeException和System.OverflowException

时间:2019-07-06 14:30:02

标签: azure asp.net-core azure-web-app-service asp.net-core-2.1

今天,我已经为我的Azure App Serivce:.NET Core 2.1 Web API调整了 App服务日志设置。将应用程序日志记录(文件系统)设置从“信息”更改为“警告”后不久,我的应用程序停止响应。我立即使用诊断并解决问题功能启动了.NET跟踪。

此跟踪报告显示以下内容:

system.private.corelib!
microsoft.aspnetcore.hosting!
System.Private.CoreLib!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
microsoft.aspnetcore.hosting.il!Microsoft.AspNetCore.Hosting.Views.ErrorPage.ExecuteAsync
microsoft.aspnetcore.hosting!
System.Private.CoreLib!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
microsoft.aspnetcore.hosting.il!Microsoft.Extensions.RazorViews.BaseView.ExecuteAsync
microsoft.aspnetcore.hosting!
microsoft.aspnetcore.hosting!
System.Private.CoreLib!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1+<>c[System.Threading.Tasks.VoidTaskResult,Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol+<ProcessRequests>d__188`1[Microsoft.AspNetCore.Hosting.Internal.HostingApplication+Context]].<.cctor>b__9_0
system.private.corelib!
System.Private.CoreLib!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[System.Threading.Tasks.VoidTaskResult,Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol+<ProcessRequests>d__188`1[Microsoft.AspNetCore.Hosting.Internal.HostingApplication+Context]].MoveNext
system.private.corelib!
system.private.corelib!
system.private.corelib!
system.private.corelib!
system.private.corelib! 

同一时间,Azure Blob日志显示以下行:

2019-07-06 14:04:06.476 +00:00 [Error] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLO233NHLK6Q", Request id "0HLO233NHLK6Q:000003BF": An unhandled exception was thrown by the application.
System.OverflowException: Arithmetic operation resulted in an overflow.
   at System.IO.StreamWriter.Write(String value)
   at Microsoft.Extensions.RazorViews.BaseView.Write(String value)
   at Microsoft.AspNetCore.Hosting.Views.ErrorPage.ExecuteAsync()
   at Microsoft.Extensions.RazorViews.BaseView.ExecuteAsync(HttpContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

2019-07-06 14:04:19.245 +00:00 [Error] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLO233NHLK6T", Request id "0HLO233NHLK6T:000000EF": An unhandled exception was thrown by the application.
System.ArgumentOutOfRangeException: Index and count must refer to a location within the buffer.
Parameter name: chars
   at System.Text.EncoderNLS.GetBytes(Char[] chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, Boolean flush)
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.StreamWriter.Write(String value)
   at Microsoft.AspNetCore.Hosting.Views.ErrorPage.ExecuteAsync()
   at Microsoft.Extensions.RazorViews.BaseView.ExecuteAsync(HttpContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

这些堆栈跟踪没有显示我自己的任何代码,它们似乎与框架相关。

这些错误堆栈跟踪中是否有消息或提示可用来防止这些情况发生?

非常感谢

1 个答案:

答案 0 :(得分:0)

我知道为时已晚,但也许我的回答会帮助其他人。 我收到了与您相同的例外。但这不是Azure应用服务,而是IIS。问题出在Startup.cs中某个地方的配置不正确。您的虚拟主机尝试显示错误页面,但同时App Service(或我的情况下为IIS)试图关闭或重新启动它。

该主题对我有很大帮助https://github.com/aspnet/KestrelHttpServer/issues/1737