简体   繁体   中英

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...

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 ....

but after some googling I crossed to this which said Inproc mode is not reliable and unexpected Process Recycling

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. 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.

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 ?

My web.config and IIS:

<sessionState timeout="120" mode="InProc"></sessionState>

在此输入图像描述

UPDATE:

From what I have tested I can see Application get restarted not AppPool or w3wp .

I have get exception in Application_Error but still there is no clue to know

   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)

  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() .

they may returns large JSON string so is there limitation for response.Write() that reset application ?

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.

Step 1 : So I improved my Application_End logging as:

 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:

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 , Int32 flags)

Step 3: Googling about IIS configuration change at last found proper Microsoft KB about unexpected ASP.Net application shutdown

Step 4: Download All supported x64-based versions of Windows Server 2012 R2 package and installed it on mentioned server.

Step 5: Calm down and be happy because the problem has been resolved by 4 mentioned steps!!!!

I hope it be useful for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM