[英]Application restarted unexpectedly on Server 2012 and IIS 8.5
在用户登录并执行一些并发后, $.ajax
会话意外过期或应用程序重新启动...
我检查了每个工具,以了解主要原因,如Win事件日志,IIS日志和我的自定义日志信息,但没有正确的信息....
但经过一些谷歌搜索,我越过了这个说Inproc
模式是不可靠和意外的过程回收
或者问题的答案在这里说如果你使用InProc
会话状态并且AppPool
旋转,那将自动重置登录用户的所有会话。 因此,请确保您使用其他方法进行会话状态,或者AppPool
的空闲超时时间长于.NET
会话超时。
谁能告诉我,我错了什么?
或者$.ajax
限制发布数据或webmethod
返回的字符串len的webmethod
导致此问题?
我的web.config
和IIS:
<sessionState timeout="120" mode="InProc"></sessionState>
更新:
根据我的测试,我可以看到Application重新启动而不是AppPool
或w3wp
。
我在Application_Error
遇到异常但仍无法知道
void Application_Error(object sender, EventArgs e)
{
_logging = new Logging(Global.LogPath);
Exception exp = Server.GetLastError();
_logging.Log(LoggingMode.Error, "An error accured through the application, EX{0}", exp.ToString());
}
我也按照这个链接做了所说的但没什么不同。
更新:
在另一边我有一个通用的处理程序来处理一些$.ajax
请求(并发请求)
public override void ProcessRequest(HttpContext context)
{
base.ProcessRequest(context);
HttpRequest request = context.Request;
HttpResponse response = context.Response;
response.ContentType = "text/plain";
string action = request["Action"];
switch (action)
{
case "LoadThumbnails":
response.Write(LoadThumbnails(request.GetStudyUid()));
break;
case "LoadDetails":
string detailsSeriesUid = request["seriesUID"];
string detailsStartPoint = request["strStartPoint"];
string detailsLengthPoint = request["strLenghtPoint"];
response.Write(LoadDetails(request.GetStudyUid(), detailsSeriesUid, detailsStartPoint, detailsLengthPoint));
break;
.
.
.
有时应用程序在LoadThumbnails()
重新启动,有时在LoadDetails()
重新启动。
他们可能会返回大的JSON字符串,因此对于重置应用程序的response.Write()
有限制吗?
提前致谢。
啊哈,经过多次头痛我已经妥善解决了这个问题....
正如微软提到的那样,这个问题是由于磁盘I / O较高而且我有一个并发$.ajax
请求从服务获取流并将其写入wbserver HDD所以我将在这里发布解决方案可能会帮助某人。
第1步:所以我改进了我的Application_End
日志记录:
void Application_End(object sender, EventArgs e)
{
if (Logging == null)
Logging = new Logging(ConfigurationManager.AppSettings["LogFile"]);
int logLevel = Convert.ToInt32(ConfigurationManager.AppSettings["LogLevel"].ToString());
Logging.Mode = (LoggingMode)logLevel;
Logging.Log(LoggingMode.Error, "Application_End is running...");
HttpRuntime runtime = (HttpRuntime)typeof(HttpRuntime).InvokeMember("_theRuntime", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null);
if (runtime == null)
{
Logging.Log(LoggingMode.Error, "Runtime is null...");
return;
}
string shutDownMessage = (string)runtime.GetType().InvokeMember("_shutDownMessage", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null);
string shutDownStack = (string)runtime.GetType().InvokeMember("_shutDownStack", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null);
Logging.Log(LoggingMode.Error, "Application restarted because of , Message:{0} , Stack:{1}", shutDownMessage, shutDownStack);
}
第2步:意外重启后的日志是:
2016-12-28 13:33:41.4791 [错误] [myApp.dll] Application_End正在运行... 2016-12-28 13:33:41.4822 [错误] [myApp.dll]应用程序因Message:IIS配置重新启动更改HostingEnvironment启动关闭HostingEnvironment导致关闭,Stack:System.Environment.GetStackTrace(Exception e,Boolean needFileInfo),位于System.Web.Hosting.HostingEhvironment.InitiateShutdownInternal()的System.Environment.get_StackTrace()处于System.Web.Hosting。 System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer,IntPtr nativeRequestContext)中的System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler,RequestNotificationStatus&notificationStatus)上的System.Web.Hosting.PipelineRuntime.StopProcessing()中的HostingEnvironment.InitiateShutdownWithoutDemand() System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer,IntPtr nativeRequestContext,IntPtr moduleData),IntPtr moduleData,Int32 flags) ,Int32标志)
第3步:谷歌搜索IIS配置更改最后找到适当的Microsoft KB关于意外的ASP.Net应用程序关闭
步骤4:下载All supported x64-based versions of Windows Server 2012 R2
软件包All supported x64-based versions of Windows Server 2012 R2
并将其安装在上述服务器上。
第五步:冷静下来,快乐,因为问题已通过4个步骤得到解决!
我希望它对你有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.