问题
I'm investigating Microsoft's reverse-AJAX sample wherein they use a long timeout in the ScriptManager
<asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="2147483647">
And a ManualResetEvent to control the wait:
private ManualResetEvent messageEvent = new ManualResetEvent(false);
public Message DequeueMessage()
{
// Wait until a new message.
messageEvent.WaitOne();
}
public void EnqueueMessage(Message message)
{
lock (messageQueue)
{
messageQueue.Enqueue(message);
// Set a new message event.
messageEvent.Set();
}
}
I've noticed that
- Setting AsyncPostBackTimeout to a low value (5) does not cause the script to timeout or fail
<httpRuntime executionTimeout="5"/>
in web.config does not seem to have an effectThe following javascript doesn't appear to run when execution takes too long
Sys.WebForms.PageRequestManager.getInstance() .add_endRequest(function (sender, args) { if (args.get_error() && args.get_error().name === 'Sys.WebForms.PageRequestManagerTimeoutException') { alert('Caught a timeout!'); // remember to set errorHandled = true to keep from getting a popup from the AJAX library itself args.set_errorHandled(true); } });
Which makes me ask these questions
What are the correct IIS settings and .js callbacks that affect the execution of this code?
What portions of the IIS infrastructure are stressed when this application scales?
Does anything in #2 change if this becomes a WAS-based WCF service?
回答1:
The unit of the value of AsyncPostBackTimeout is second, so 5 means 5 seconds, of course we don't need 5 seconds to wait callback. The ExecutionTimeout property indicates the maximum number of seconds a request is allowed to execute before being automatically shut down by ASP.NET. The default is 110 seconds. This time-out applies only if the debug attribute in the element is set to false.
•The following javascript doesn't appear to run when execution takes too long
How could you know the execution takes too long?
1.What are the correct IIS settings and .js callbacks that affect the execution of this code?
We don't need special settings in IIS for this sample. Only network issue could cause the execution timeout.
I'm confused why you want to focus on the timeout, did you get unhandled exception when you use my sample?
Jerry Weng - MSFT
来源:https://stackoverflow.com/questions/5735240/scaling-microsofts-asp-net-reverse-ajax-long-poll-codeplex-example