System.Threading.ThreadAbortException when executing remote web service RRS feed

  • Question

  • User-816053008 posted

    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

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

    - EventData

    An unhandled exception has occurred.
    6/12/2007 1:26:49 PM
    6/12/2007 8:26:49 PM
    Thread was being aborted.
    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)





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

    - EventData

    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)
    Tuesday, June 12, 2007 4:59 PM

All replies

  • User1073881637 posted

    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.

    Thursday, June 14, 2007 10:44 PM
  • User-816053008 posted

    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:

    • General 
      • .NET Framework Version : 2.0
      • Enable 32-bit Apps : False
      • Managed Pipeline : Classic
      • Queue Length : 1000
      • Start Automatically : true
    • CPU
      • Limit : 0
      • LimitAction : NoAction
      • LimitInterval : 5
      • Proc. Affinity Enabled : false
      • Proc. Affinity Mask : 4294967295
    • Process Model
      • Identity : NetworkService
      • Idle Timeout : 20 minutes
      • Max. Worker Processes: 1
      • Ping Enabled : False
      • Ping Max Response Time: 90 secs
      • Ping Period : 30 secs
      • Shutdown Time Limit: 1800 secs
      • Startup Time LImit: 90 secs
    • Process Orphaning
      • Enabled : False
      • Executable :
      • Executable Params:
    • Rapid Fail Protection
      • "Service Unavailable" response type: HttpLevel
      • Enabled : fasle
      • failure interval : 5 mins
      • max failures : 5
      • Shutdown executable:
      • Shutdown executable params:
    • Recycling
      • Disable Overlapped Recycle: False
      • Disable Recycling for Configuration Changes: False
      • Private Memory Limit : 0
      • Regular Time Intervals : 0
      • Request Limit : 0
      • Virtual Memory : 0
    Monday, June 18, 2007 1:21 PM
  • User1384820898 posted

    Hi jim.klo

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

    Thanks in advance. 

    Tuesday, December 11, 2007 12:27 PM
  • User-765123313 posted

    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:

    Guy Forsyth Discussing the problem


    Hopes this helps someone...


    Wednesday, April 2, 2008 4:16 PM