System.Threading.ThreadAbortException when executing remote web serviceRSS

4 replies

Last post Apr 02, 2008 04:16 PM by lethargicgeek

  • System.Threading.ThreadAbortException when executing remote web service

    Jun 12, 2007 04:59 PM|jim.klo|LINK

    I'm in the process of moving a set of web services that currently work under IIS 6 on Windows 2003 Server, to run on Windows Vista Ultimate, IIS 7.

     Everything seems to be working, with the exception of  each I try to execute a synchronous remote web service that has a long execution time  running on IIS 7 / Vista Ultimate, after about 2 - 3 minutes, a System.Threading.ThreadAbortException is thrown at the provider end of the web service, which can't be caught.  It appears to be a timeout issue, however I've set all the timeouts, that I could find to 1 hour, and even then the new timeout settings are either not being honored or I'm missing a setting which may be new to IIS 7.

     Can anyone possibly provide some insight into what my issue might be, and how to resolve it?

    Here's the stacktraces:


    [ThreadAbortException: Thread was being aborted.]
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +495
       System.Web.ApplicationStepManager.ResumeSteps(Exception error) +531
       System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +140
       System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +403

    Version Information: Microsoft .NET Framework Version:2.0.50727.312; ASP.NET Version:2.0.50727.312
    --.
    Source: System.Web.Services
    Exception Type: System.InvalidOperationException
    StrackTrace: at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
    at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
    at ServiceProxies.Net.NAntServiceSoap.ExecuteNAntTemporaryTask(String nantScriptFileContents, DirectoryFSO workingDirectory, String arguments) in C:\work\dotNET\Utilities\WADeploy\trunk\ServiceProxies\Net\NAntServiceSoap.cs:line 152
    at WADeployTool.Support.TargetDeployer.PerformNAntTask(NAntServiceSoap nantProxy, NAntTaskStaticCopy currentTask, ThreadDeploymentArgs args) in C:\work\dotNET\Utilities\WADeploy\trunk\WADeployTool\Support\TargetDeployer.cs:line 746

     

    Here are the errors in the event viewer:

    - System

    <div>
    - Provider
    <div>
    [ Name] ASP.NET 2.0.50727.0
    </div>
    - EventID 1309
    <div>
    [ Qualifiers] 32768
    </div>
    Level 3
    Task 3
    Keywords 0x80000000000000
    - TimeCreated
    <div>
    [ SystemTime] 2007-06-12T20:26:49.000Z
    </div>
    EventRecordID 6160
    Channel Application
    Computer XXXXXX
    Security
    </div>

    - EventData

    <div>
    3005
    An unhandled exception has occurred.
    6/12/2007 1:26:49 PM
    6/12/2007 8:26:49 PM
    a2f473a8da5c42d8947e6870c6071fdc
    23
    1
    0
    /LM/W3SVC/3/ROOT-1-128261534809598000
    Full
    /
    C:\DeployService\
    XXXXXX
    5784
    w3wp.exe
    NT AUTHORITY\NETWORK SERVICE
    ThreadAbortException
    Thread was being aborted.
    http://localhost:3450/NAntService.asmx
    /NAntService.asmx
    ::1
    XXXXXXX
    True
    Negotiate
    NT AUTHORITY\NETWORK SERVICE
    5
    NT AUTHORITY\NETWORK SERVICE
    False
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) at System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error) at System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
    </div>

    AND

     

    -

    System

    <div>
    - Provider
    <div>
    [ Name] ASP.NET 2.0.50727.0
    </div>
    </div> <div>
    - EventID 1073
    <div>
    [ Qualifiers] 32768
    </div>
    </div> <div>
    Level 3
    </div> <div>
    Task 0
    </div> <div>
    Keywords 0x80000000000000
    </div> <div>
    - TimeCreated
    <div>
    [ SystemTime] 2007-06-12T20:26:49.000Z
    </div>
    </div> <div>
    EventRecordID 6161
    </div> <div>
    Channel Application
    </div> <div>
    Computer XXXXXX
    </div> <div>
    Security
    </div>

    - EventData

    <div>
    Failed to process request. Exception: System.AppDomainUnloadedException Message: Attempted to access an unloaded AppDomain. StackTrace: at System.Web.Hosting.ApplicationManager.RespondToPingIfNeeded() at System.Web.Hosting.HostingEnvironment.RespondToPingButNotTooOften() at System.Web.Hosting.HostingEnvironment.DecrementBusyCountInternal() at System.Web.HttpRuntime.FinishRequest(HttpWorkerRequest wr, HttpContext context, Exception e) at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) at System.Web.HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr) at System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
    </div>
  • Re: System.Threading.ThreadAbortException when executing remote web service

    Jun 14, 2007 10:44 PM|steve schofield|LINK

    Which mode is the application pool running as? Integrated or Classic Mode.  Try running your code in Classic Mode and see if you see the same behavior.

    Steve Schofield
    Windows Server MVP - IIS
    http://iislogs.com/steveschofield
    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget

  • Re: System.Threading.ThreadAbortException when executing remote web service

    Jun 18, 2007 01:21 PM|jim.klo|LINK

    I'm actually already running the application pool in Classic Mode.  I've tried disabling most features, which seems to not effect anything.

    Here are my app pool settings:

    • <div mce_keep="true">General </div>
      • <div mce_keep="true">.NET Framework Version : 2.0</div>
      • <div mce_keep="true">Enable 32-bit Apps : False</div>
      • <div mce_keep="true">Managed Pipeline : Classic</div>
      • <div mce_keep="true">Queue Length : 1000</div>
      • <div mce_keep="true">Start Automatically : true</div>
    • <div mce_keep="true">CPU</div>
      • <div mce_keep="true">Limit : 0</div>
      • <div mce_keep="true">LimitAction : NoAction</div>
      • <div mce_keep="true">LimitInterval : 5</div>
      • <div mce_keep="true">Proc. Affinity Enabled : false</div>
      • <div mce_keep="true">Proc. Affinity Mask : 4294967295</div>
    • <div mce_keep="true">Process Model</div>
      • <div mce_keep="true">Identity : NetworkService</div>
      • <div mce_keep="true">Idle Timeout : 20 minutes</div>
      • <div mce_keep="true">Max. Worker Processes: 1</div>
      • <div mce_keep="true">Ping Enabled : False</div>
      • <div mce_keep="true">Ping Max Response Time: 90 secs</div>
      • <div mce_keep="true">Ping Period : 30 secs</div>
      • <div mce_keep="true">Shutdown Time Limit: 1800 secs</div>
      • <div mce_keep="true">Startup Time LImit: 90 secs</div>
    • <div mce_keep="true">Process Orphaning</div>
      • <div mce_keep="true">Enabled : False</div>
      • <div mce_keep="true">Executable : </div>
      • <div mce_keep="true">Executable Params:</div>
    • <div mce_keep="true">Rapid Fail Protection</div>
      • <div mce_keep="true">"Service Unavailable" response type: HttpLevel</div>
      • <div mce_keep="true">Enabled : fasle</div>
      • <div mce_keep="true">failure interval : 5 mins</div>
      • <div mce_keep="true">max failures : 5</div>
      • <div mce_keep="true">Shutdown executable:</div>
      • <div mce_keep="true">Shutdown executable params:</div>
    • <div mce_keep="true">Recycling</div>
      • <div mce_keep="true">Disable Overlapped Recycle: False</div>
      • <div mce_keep="true">Disable Recycling for Configuration Changes: False</div>
      • <div mce_keep="true">Private Memory Limit : 0</div>
      • <div mce_keep="true">Regular Time Intervals : 0</div>
      • <div mce_keep="true">Request Limit : 0</div>
      • <div mce_keep="true">Virtual Memory : 0</div>
  • Re: System.Threading.ThreadAbortException when executing remote web service

    Dec 11, 2007 12:27 PM|edelriomartin|LINK

    Hi jim.klo

    Have you found a solution for this problem? I have a very similar situation. 

    Thanks in advance. 

  • Re: System.Threading.ThreadAbortException when executing remote web service

    Apr 02, 2008 04:16 PM|lethargicgeek|LINK

    This may or may not be relevant... but are you modifying any files/directories in your application folder at runtime?

    In .Net 2.0 and later, the AppDomain is restarted whenever the file structure is heavily modified.  This causes all threads that do not wrap up in a timely fashion to be aborted.  Meaning, if your thread is fast enough, it won't be touched.  This is different than .net 1.1 where it was only the web.config and bin files that were monitored. 

    I myself was frustrated in figuring out why I could parse though a 100k file fine but my application threw ThreadAbortExceptions on a 500k file.  I killed hours playing with timeouts and configs before finding the solution. 

     Solution I used to disable File Monitoring:
    (requires using System.Reflection)

    PropertyInfo p = typeof(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
    object o = p.GetValue(null, null);
    FieldInfo f = o.GetType().GetField("_dirMonSubdirs", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase);
    object monitor = f.GetValue(o);
    MethodInfo m = monitor.GetType().GetMethod("StopMonitoring", BindingFlags.Instance | BindingFlags.NonPublic);
            m.Invoke(monitor, new object[] { });

     

    Two good references on the problem:

    The formal Complaint:
    http://connect.microsoft.com/VisualStudio/feedback/Workaround.aspx?FeedbackID=240686

    Guy Forsyth Discussing the problem
    http://weblogs.asp.net/owscott/archive/2006/02/21/ASP.NET-v2.0-_2D00_-AppDomain-recycles_2C00_-more-common-than-before.aspx

     

    Hopes this helps someone...
     


     
     

    troubleshooting threadabortexception appdomain timeout