Video Screencast Help

Thread Aborted - Workflow Timed Out?

Created: 02 Mar 2012 • Updated: 20 Jul 2012 | 17 comments
mlee22's picture
This issue has been solved. See solution.

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.

Comments 17 CommentsJump to latest comment

Rob Moore's picture

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


mlee22's picture

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.

Rob Moore's picture

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.


mlee22's picture

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

AnaMan's picture

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.

AnaMan's picture

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

mlee22's picture

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

mlowe's picture

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.


mlee22's picture

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?

reecardo's picture

httpRuntime is nested like this in a web.config:



<httpRuntime... >



mlee22's picture

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

reecardo's picture

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

mlee22's picture

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.

AnaMan's picture

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".

mlee22's picture

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,


AnaMan's picture

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

So 30000 is more than 8 hours!

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

mlowe's picture

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.