Tuesday, July 31, 2012

[TroubleShooting] JMeter on IIS Response code: 500

今天在試壓力測試,使用的軟體是Apache JMeter,同事在demo這套軟體時,是對php去作壓力測試,看起來都ok,但是我自己對在IIS上一個有掛元件的aspx測試,怎麼測Response code都是給我500 Internal Server Error,但是網頁直接開起來卻是正常的,想來想去找不出頭緒來,後來請教同事,才發現是少給了東西才導致錯誤。

IIS給出的錯誤敘述大概是這樣

在此內容中無法使用要求

描述: 在執行目前 Web 要求的過程中發生未處理的例外情形。請檢閱堆疊追蹤以取得錯誤的詳細資訊,以及在程式碼中產生的位置。
例外詳細資訊: System.Web.HttpException: 在此內容中無法使用要求
原始程式錯誤:
在執行目前 Web 要求期間,產生未處理的例外狀況。如需有關例外狀況來源與位置的資訊,可以使用下列的例外狀況堆疊追蹤取得。

然後是能看到的所有錯誤追蹤
[HttpException]: 在此內容中無法使用要求
於 System.Web.UI.Page.InitializeWriter(HtmlTextWriter writer)
於 System.Web.UI.Page.Render(HtmlTextWriter writer)
於 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
於 System.Web.UI.HtmlControls.HtmlHead.RenderChildren(HtmlTextWriter writer)
於 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
於 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
於 System.Web.UI.Page.Render(HtmlTextWriter writer)
於 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
[HttpUnhandledException]: 已發生類型 'System.Web.HttpUnhandledException' 的例外狀況。
於 System.Web.UI.Page.HandleError(Exception e)
於 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
於 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
於 System.Web.UI.Page.ProcessRequest()
於 System.Web.UI.Page.ProcessRequest(HttpContext context)
於 ASP.test_aspx.ProcessRequest(HttpContext context) 於 c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\b6117787\15ef29eb\App_Web_iymdrjeu.0.cs: 行 0
於 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
於 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

其實除了看起來不像是程式上哪邊寫錯,也沒什麼幫助,所以我就這樣卡很久了

結果後來同事試了一下,發現加上User-Agent就可以了......我卡了一個上午是何苦 -_-

JMeter

所以解決方案是,在[HTTP Header Manager]內,新增一個Header叫"User-Agent",Value只要是一個合理的值就行,亂打還是會掛掉,我是去看IIS log然後抄Chrome給的,所以填上"Mozilla/5.0+(Windows+NT+6.1;+WOW64)+AppleWebKit/536.11+(KHTML,+like+Gecko)+Chrome/20.0.1132.57+Safari/536.11",然後測試一下,成功。

可賀可喜,再度收工。

No comments:

Post a Comment