Workflow and ServiceDesk Community

 View Only
Expand all | Collapse all

Thread Aborted - Workflow Timed Out?

  • 1.  Thread Aborted - Workflow Timed Out?

    Posted Mar 02, 2012 04:53 PM
    I have a workflow with an Execute and Wait component that runs a remote script. This script runs a distributed search based on the parameters passed in over multiple servers. The total time it takes to complete is roughly ~5 minutes, and I believe IIS or workflow is assuming my process is hung up. I get the following error below:
    Error = "System.Threading.ThreadAbortException: Thread was being aborted. at Microsoft.Win32.Win32Native.ReadFile(SafeFileHandle handle, Byte* bytes, Int32 numBytesToRead, Int32& numBytesRead, IntPtr mustBeZero) at System.IO.FileStream.ReadFileNative(SafeFileHandle handle, Byte[] bytes, Int32 offset, Int32 count, NativeOverlapped* overlapped, Int32& hr) at System.IO.FileStream.ReadCore(Byte[] buffer, Int32 offset, Int32 count) at System.IO.FileStream.Read(Byte[] array, Int32 offset, Int32 count) at System.IO.StreamReader.ReadBuffer() at System.IO.StreamReader.ReadToEnd() at LogicBase.Components.Default.ExecuteProcessAndWait.Run(IData data)"
    Reducing the script complexity and removing the distributed search, my workflow runs fine. Any ideas on how to resolve this problem? I feel like it's a default timeout setting that needs to be overwritten.


  • 2.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 02, 2012 11:07 PM

    I believe the timeout per component is 3 minutes, that is no single component can run for more than 3 minutes. There may be a way to extend this via a web.config setting, but I am not sure how.

     

    You may want to change the component from execute an wait to just an execute, then put a loop in place that checks to see if the script is done. If not, pause for 30 seconds, then check again, etc...

     

    Rob



  • 3.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 05, 2012 03:41 AM

    The crucial information is if this Execute and Wait component is executed inside any Workflow component (like Dialog Workflow) or outside of such components.



  • 4.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 05, 2012 10:09 AM

    You can enter the following line of code just after the <system.web> line in the web.config.  (This is case sensitive)

    <httpRuntime executionTimeout="300000"/>

    Then do an IIS Reset and restart the server extensions.

     

    Matt



  • 5.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 05, 2012 11:37 AM

    Workflow gives me an error when I run the debugger complaining about the syntax of my web.config file when I add that line under the <system.web> tab.  If what Rob Moore said is true, then wouldn't this setting not have an effect on the workflow?



  • 6.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 05, 2012 11:39 AM

    No, it is not inside a dialog workflow component.  It is a standard web-service workflow process.



  • 7.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 05, 2012 11:41 AM

    httpRuntime is nested like this in a web.config:

    <configuration>

    <system.web>

    <httpRuntime... >

    </system.web>

    </configuration>



  • 8.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 05, 2012 11:46 AM

    Not sure if you've implemented the pause and check again method, but since I'm running this script remotely on another server, I have to do the following pseudocode (pseudocomponents?):

    - Run Execute Process to start the script

    - Loop until process is complete

        - Run Execute Process and Wait to check if process is finished

        - If process not complete

            - Pause execution for 30 seconds

        - Else

            - Break

    The issue now is with the Run Execute Process and Wait component that checks to see if the process is complete.  When I have standard output selected and call the same component, it complains my standard output variable is an array type and the field cannot be this type.  It gets output as a String and not an array, so I have no idea why it thinks this is an array when I try to loop the two components.



  • 9.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 05, 2012 11:49 AM

    When that line is added to the web.config, the following error is displayed:



  • 10.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 05, 2012 11:54 AM

    OK, when I say ..., I mean all the things you can declare in httpRuntime. Don't copy that over specifically.

     

    I would try amending the web.config after deploying the WF (after first backing up the original web.config). There are loads of examples online of what a well-formed system.web node in a web.config looks like



  • 11.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 05, 2012 01:41 PM

    It depends on where that line of code is added.  I have never had an issue with it when added right after the <system.web> tag.  It all depends on what is causing the timeout.  Most of the workflow pages have the default 2 minute timeout which this should fix. 

    If you are calling a web service, the component that does the call most likely has its own timeout setting on it which is usually 30000 which is only 30 seconds.  That could also be raised.



  • 12.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 05, 2012 02:10 PM

    Whenever you run a component with single line outputs in a loop workflow seems to complain about the output not being an array. I think it's trying to add another element with the same name, and that is "fooling" wf into thinking the output should be capable of storing multiple values - hence the array error.

    To solve this, put the second Run and Wait into an embedded model. In that embedded model, you'll have to have some logic that sets a true/false condition (true if it's complete, false if it's not). Now set the output data of the embedded model to only be the T/F variable. hook up a True/False rule after the embedded model. If true then continue, it false, back to the loop.

    Any data created before an embedded model is visible to the embedded model. Any data created INSIDE the embedded model is not visible outside that model, unless you explicitly set an output variable.

    Rob



  • 13.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 06, 2012 12:27 AM

    Even with the pauses implemented, my thread times out.  I have a feeling this has to do with IIS and not Workflow anymore.



  • 14.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 06, 2012 12:37 AM

    I realize there are different attributes/values that go within an httpRuntime tag.  What I was trying to point out is that when this XML tag is added under <system.web>, the debugging and IIS throws an error declaring this tag as invalid.

    I have tried changing the all the timeout settings within IIS, but I have not been able to get it to work.  I don't think it's a question of how to add the delay in.  It's a question of which web.config file does it go into?  I am not an IIS SME, but it seems that it is definitely an issue with the process timing out.



  • 15.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 06, 2012 06:50 AM

    I'm afraid this mismatch between expected and allowed data type seems to be a bug.

    I've looked into this assembly and it's occured that Output variable has set attribute VariableType(typeof(string), true, true) restricting Select Variable dialog only to variables being arrays of strings (the first boolean value defines if variable must be an array). But at execution time this components returns data just as a string.



  • 16.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 06, 2012 07:12 AM

    The value of executionTimeout attribute is specified in SECONDS - not in miliseconds:

    http://msdn.microsoft.com/en-us/library/e1f13641(v=vs.90).aspx

    So 30000 is more than 8 hours!

    I think it's not to healthy for web server.



  • 17.  RE: Thread Aborted - Workflow Timed Out?

    Posted Mar 06, 2012 07:18 AM

    I know that this questions is a bit naive.

    Are you sure you are using a proper text editor for editing web.config?

    Web.config is an XML file in UTF-8 encoding and when it is written by wrong editor (for instance in ASCII encoding) then it is possible mismatch beetween "html/text" and "html/xml".



  • 18.  RE: Thread Aborted - Workflow Timed Out?
    Best Answer

    Posted Mar 06, 2012 03:38 PM

    The primary issue was that I was calling my web service using a web browser and submitting an HTTP request, which is prone to being aborted after the default 90 seconds.  When you initiate this web service call programmatically through a proper web service call, this timeout does not apply to the process and my process completes.

    The editor I used was notepad and I opened the file in UTF-8 encoding and saved the file by simply adding a comment.  This worked fine, so the editor was not the issue.  I believe the way to resolve this is to edit the web.config or machine.config for ASP's .NET Framework.  This is located under C:\Windows\Microsoft.NET\.... depending on which version your AppPool is running with.

    Thanks for everyone's help,

    ~Mark