ASP.NET 5(RC1)错误网关:指定的CGI应用程序遇到错误,服务器终止该进程 [英] ASP.NET 5 (RC1) Bad Gateway: The specified CGI application encountered an error and the server terminated the process
问题描述
我运行在Azure的Web应用程序的ASP.NET项目5
在约1.5MB或文件(表格数据)上的API调用端点时,我收到了 502网关错误
在该效应初探后续消息正文:
指定的CGI应用程序遇到错误,服务器
终止该进程。
块引用>但奇怪的是,上传一个较小的文件时,呼叫工作正常。它似乎产生
502
在周围的1.5MB大关,但它并不完全一致。我使用ASP.NET 5 RC1。
在Startup.cs,我有
app.UseIISPlatformHandler();
作为第一个中间件除了在配置()
方法。
project.config:
{
...
根目录:wwwroot的
依赖:{
Microsoft.ApplicationInsights.AspNet:1.0.0-RC1
Microsoft.AspNet.Mvc:6.0.0-RC1决赛
Microsoft.AspNet.Server.Kestrel:1.0.0-RC1决赛
Microsoft.AspNet.Diagnostics:1.0.0-RC1决赛
Microsoft.AspNet.Authorization:1.0.0-RC1决赛
Microsoft.AspNet.Mvc.Core:6.0.0-RC1决赛
Microsoft.AspNet.Mvc.Abstractions:6.0.0-RC1决赛
Microsoft.AspNet.Authentication.JwtBearer:1.0.0-RC1决赛
Microsoft.Extensions.PlatformAbstractions:1.0.0-RC1决赛
Microsoft.AspNet.StaticFiles:1.0.0-RC1决赛
Microsoft.Extensions.Logging:1.0.0-RC1决赛
Microsoft.Extensions.Logging.Abstractions:1.0.0-RC1决赛
Microsoft.Extensions.Configuration:1.0.0-RC1决赛
Microsoft.Extensions.Configuration.Json:1.0.0-RC1决赛
Microsoft.Extensions.Configuration.EnvironmentVariables:1.0.0-RC1决赛
Newtonsoft.Json:6.0.6,
WindowsAzure.Storage:5.0.2,
Microsoft.AspNet.IISPlatformHandler:1.0.0-RC1决赛
...
},
命令:{
网络:Microsoft.AspNet.Server.Kestrel
},
构架: {
dnx451:{}
},
}编辑:
正如Jessevl建议,以下异常被抛出:
System.IO.InvalidDataException:在请求内容的意外结束
Microsoft.AspNet.Server.Kestrel.Http.MessageBody.ForContentLength.d__3.MoveNext()
---从previous位置堆栈跟踪,其中引发异常---在结束
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在
Microsoft.AspNet.WebUtilities.FileBufferingReadStream.d__27.MoveNext()
---从previous位置堆栈跟踪,其中引发异常---在结束
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在
Microsoft.AspNet.WebUtilities.BufferedReadStream.d__39.MoveNext()---
从previous位置堆栈跟踪到底哪里抛出异常
---在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在
Microsoft.AspNet.WebUtilities.MultipartReaderStream.d__36.MoveNext()
---从previous位置堆栈跟踪,其中引发异常---在结束
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在
Microsoft.AspNet.WebUtilities.StreamHelperExtensions.d__0.MoveNext()
---从previous位置堆栈跟踪,其中引发异常---在结束
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(任务
任务)在
Microsoft.AspNet.Http.Features.Internal.FormFeature.d__12.MoveNext()
---从previous位置堆栈跟踪,其中引发异常---在结束
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在
Microsoft.AspNet.Mvc.ModelBinding.FormValueProviderFactory.d__1.MoveNext()
---从previous位置堆栈跟踪,其中引发异常---在结束
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在
Microsoft.AspNet.Mvc.ModelBinding.CompositeValueProvider.d__2.MoveNext()
---从previous位置堆栈跟踪,其中引发异常---在结束
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(任务
任务)在
Microsoft.AspNet.Mvc.Controllers.FilterActionInvoker.d__49.MoveNext()
---从previous位置堆栈跟踪,其中引发异常---在结束
Microsoft.AspNet.Mvc.Controllers.FilterActionInvoker.d__44.MoveNext()
---从previous位置堆栈跟踪,其中引发异常---在结束
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在
Microsoft.AspNet.Mvc.Infrastructure.MvcRouteHandler.d__6.MoveNext()
---从previous位置堆栈跟踪,其中引发异常---在结束
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在
Microsoft.AspNet.Mvc.Routing.InnerAttributeRoute.d__10.MoveNext()---
从previous位置堆栈跟踪到底哪里抛出异常
---在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在Microsoft.AspNet.Routing.RouteCollection.d__9.MoveNext()---
从previous位置堆栈跟踪到底哪里抛出异常
---在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在Microsoft.AspNet.Builder.RouterMiddleware.d__4.MoveNext()---
从previous位置堆栈跟踪到底哪里抛出异常
---在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在
Microsoft.ApplicationInsights.AspNet.RequestTrackingMiddleware.d__4.MoveNext()
---从previous位置堆栈跟踪,其中引发异常---在结束
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在
Microsoft.AspNet.IISPlatformHandler.IISPlatformHandlerMiddleware.d__8.MoveNext()
---从previous位置堆栈跟踪,其中引发异常---在结束
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在
Microsoft.AspNet.Hosting.Internal.RequestServicesContainerMiddleware.d__3.MoveNext()
---从previous位置堆栈跟踪,其中引发异常---在结束
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在
Microsoft.AspNet.Hosting.Internal.HostingEngine<> c__DisplayClass32_0.d.MoveNext()
---从previous位置堆栈跟踪,其中引发异常---在结束
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务
任务)在
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务
任务)在Microsoft.AspNet.Server.Kestrel.Http.Frame.d__79.MoveNext()
块引用>解决方案似乎有某种与Asp.Net 5当前版本的问题,其中的误差在Azure的Web应用程序运行将永远是返回时, p>
指定的CGI应用程序遇到错误,服务器终止该进程。
块引用>不管实际的错误是什么。我举个例子,当我在code某处有一个不正确的连接字符串的Azure活动中心得到这个错误。
您可以尝试远程调试(见<一href=\"https://azure.microsoft.com/nl-nl/documentation/articles/web-sites-dotnet-troubleshoot-visual-studio/#remotedebug\"相对=nofollow>这里),或者干脆利用捻,这你可以找到[websitename] .scm.azurewebsites.net扫描日志(更换[websitename]什么通常应该在[websitename] .azurewebsites .NET),或Visual Studio服务器资源管理器。
杰西
I am running an ASP.NET 5 project in an Azure Web App.
When calling on an API endpoint with a file (form-data) of about 1.5mb or larger, I get a
502 Bad Gateway
with the follow message in the reponse body:The specified CGI application encountered an error and the server terminated the process.
The strange thing is that when uploading a smaller file, the call works fine. It seems to produce the
502
at around the 1.5mb mark, but it's not entirely consistent.I am using ASP.NET 5 RC1.
In Startup.cs, I have
app.UseIISPlatformHandler();
as the first middleware addition in theConfigure()
method.
project.config:
{ ... "webroot": "wwwroot", "dependencies": { "Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1", "Microsoft.AspNet.Mvc": "6.0.0-rc1-final", "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final", "Microsoft.AspNet.Authorization": "1.0.0-rc1-final", "Microsoft.AspNet.Mvc.Core": "6.0.0-rc1-final", "Microsoft.AspNet.Mvc.Abstractions": "6.0.0-rc1-final", "Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-rc1-final", "Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc1-final", "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final", "Microsoft.Extensions.Logging": "1.0.0-rc1-final", "Microsoft.Extensions.Logging.Abstractions": "1.0.0-rc1-final", "Microsoft.Extensions.Configuration": "1.0.0-rc1-final", "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc1-final", "Newtonsoft.Json": "6.0.6", "WindowsAzure.Storage": "5.0.2", "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final", ... }, "commands": { "web": "Microsoft.AspNet.Server.Kestrel" }, "frameworks": { "dnx451": { } }, }
EDIT:
As suggested by Jessevl, the following exception is being thrown:
System.IO.InvalidDataException: Unexpected end of request content at Microsoft.AspNet.Server.Kestrel.Http.MessageBody.ForContentLength.d__3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.WebUtilities.FileBufferingReadStream.d__27.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.WebUtilities.BufferedReadStream.d__39.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.WebUtilities.MultipartReaderStream.d__36.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.WebUtilities.StreamHelperExtensions.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.AspNet.Http.Features.Internal.FormFeature.d__12.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Mvc.ModelBinding.FormValueProviderFactory.d__1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Mvc.ModelBinding.CompositeValueProvider.d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.AspNet.Mvc.Controllers.FilterActionInvoker.d__49.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNet.Mvc.Controllers.FilterActionInvoker.d__44.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Mvc.Infrastructure.MvcRouteHandler.d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Mvc.Routing.InnerAttributeRoute.d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Routing.RouteCollection.d__9.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Builder.RouterMiddleware.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.ApplicationInsights.AspNet.RequestTrackingMiddleware.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.IISPlatformHandler.IISPlatformHandlerMiddleware.d__8.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Hosting.Internal.RequestServicesContainerMiddleware.d__3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Hosting.Internal.HostingEngine.<>c__DisplayClass32_0.d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Server.Kestrel.Http.Frame.d__79.MoveNext()
解决方案There seems to be some sort of issue with the current release of Asp.Net 5 where the error returned when running in an Azure Web App will always be
The specified CGI application encountered an error and the server terminated the process.
regardless of what the actual error is. I, for example, got this error when I had an incorrect connection string to Azure Event Hub somewhere in my code.
You could try remote debugging (see here) or simply scan your logs using Kudu, which you can find on [websitename].scm.azurewebsites.net (replace [websitename] with what would normally be in [websitename].azurewebsites.net), or Visual Studio server explorer.
Jesse
这篇关于ASP.NET 5(RC1)错误网关:指定的CGI应用程序遇到错误,服务器终止该进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!