[英]Application restarted unexpectedly on Server 2012 and IIS 8.5
After user login and doing some concurrency $.ajax
session get expired unexpectedly or application get restarted... 在用户登录并执行一些并发后, $.ajax
会话意外过期或应用程序重新启动...
I have checked every tools to know the main cause such as Win Event log, IIS Log and my custom logging info but there is no proper info .... 我检查了每个工具,以了解主要原因,如Win事件日志,IIS日志和我的自定义日志信息,但没有正确的信息....
but after some googling I crossed to this which said Inproc
mode is not reliable and unexpected Process Recycling 但经过一些谷歌搜索,我越过了这个说Inproc
模式是不可靠和意外的过程回收
or the answer of question here which said if you are using InProc
session state and the AppPool
spins down, that will automatically reset all of the sessions of logged in users. 或者问题的答案在这里说如果你使用InProc
会话状态并且AppPool
旋转,那将自动重置登录用户的所有会话。 So make sure you are either using some other method for session state or that the idle timeout of the AppPool
is longer than the .NET
session timeout. 因此,请确保您使用其他方法进行会话状态,或者AppPool
的空闲超时时间长于.NET
会话超时。
can someone tell me what is my wrong ? 谁能告诉我,我错了什么?
or can $.ajax
limitation posted data or limitation of returned string len from webmethod
cause this problem ? 或者$.ajax
限制发布数据或webmethod
返回的字符串len的webmethod
导致此问题?
My web.config
and IIS: 我的web.config
和IIS:
<sessionState timeout="120" mode="InProc"></sessionState>
UPDATE: 更新:
From what I have tested I can see Application get restarted not AppPool
or w3wp
. 根据我的测试,我可以看到Application重新启动而不是AppPool
或w3wp
。
I have get exception in Application_Error
but still there is no clue to know 我在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());
}
I also follow this link and did what that said but nothing different. 我也按照这个链接做了所说的但没什么不同。
UPDATE: 更新:
in the other side I have a generic handler to process some $.ajax
request (concurrency requests) 在另一边我有一个通用的处理程序来处理一些$.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;
.
.
.
sometime application get restarted in LoadThumbnails()
and sometime in LoadDetails()
. 有时应用程序在LoadThumbnails()
重新启动,有时在LoadDetails()
重新启动。
they may returns large JSON string so is there limitation for response.Write()
that reset application ? 他们可能会返回大的JSON字符串,因此对于重置应用程序的response.Write()
有限制吗?
Thanks in advance. 提前致谢。
Aha, After many headache I have resolved the problem properly.... 啊哈,经过多次头痛我已经妥善解决了这个问题....
As Microsoft mentioned this problem occurred because of high disk I/O and I have a concurrence $.ajax
requests to get stream from Service and Write it down to wbserver HDD so I am going to post the solution here may will help someone. 正如微软提到的那样,这个问题是由于磁盘I / O较高而且我有一个并发$.ajax
请求从服务获取流并将其写入wbserver HDD所以我将在这里发布解决方案可能会帮助某人。
Step 1 : So I improved my Application_End
logging as: 第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);
}
Step 2: And my log after unexpectedly restarting was: 第2步:意外重启后的日志是:
2016-12-28 13:33:41.4791 [Error] [myApp.dll] Application_End is running... 2016-12-28 13:33:41.4822 [Error] [myApp.dll] Application restarted because of Message:IIS configuration change HostingEnvironment initiated shutdown HostingEnvironment caused shutdown , Stack: at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo) at System.Environment.get_StackTrace() at System.Web.Hosting.HostingEnvironment.InitiateShutdownInternal() at System.Web.Hosting.HostingEnvironment.InitiateShutdownWithoutDemand() at System.Web.Hosting.PipelineRuntime.StopProcessing() at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData 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 flags) ,Int32标志)
Step 3: Googling about IIS configuration change at last found proper Microsoft KB about unexpected ASP.Net application shutdown 第3步:谷歌搜索IIS配置更改最后找到适当的Microsoft KB关于意外的ASP.Net应用程序关闭
Step 4: Download All supported x64-based versions of Windows Server 2012 R2
package and installed it on mentioned server. 步骤4:下载All supported x64-based versions of Windows Server 2012 R2
软件包All supported x64-based versions of Windows Server 2012 R2
并将其安装在上述服务器上。
Step 5: Calm down and be happy because the problem has been resolved by 4 mentioned steps!!!! 第五步:冷静下来,快乐,因为问题已通过4个步骤得到解决!
I hope it be useful for you. 我希望它对你有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.