簡體   English   中英

應用程序在Server 2012和IIS 8.5上意外重新啟動

[英]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重新啟動而不是AppPoolw3wp

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

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM