开发者

Scaling Microsoft's ASP.NET Reverse AJAX "long poll" codeplex example

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 = n开发者_开发技巧ew 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 effect
  • The 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

  1. What are the correct IIS settings and .js callbacks that affect the execution of this code?

  2. What portions of the IIS infrastructure are stressed when this application scales?

  3. Does anything in #2 change if this becomes a WAS-based WCF service?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜