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

和自甴很熟 提交于 2019-12-08 03:56:46

问题


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


回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!