【问题标题】:Scaling Microsoft's ASP.NET Reverse AJAX "long poll" codeplex example缩放 Microsoft 的 ASP.NET Reverse AJAX “long poll” codeplex 示例
【发布时间】:2011-08-09 18:22:12
【问题描述】:

我正在调查 Microsoft 的 reverse-AJAX sample,他们在 ScriptManager 中使用了长时间的超时

<asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="2147483647">

还有一个 ManualResetEvent 来控制等待:

    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();
        }
    }

我注意到了

  • 将 AsyncPostBackTimeout 设置为较低的值 (5) 不会导致脚本超时或失败
  • web.config 中的&lt;httpRuntime executionTimeout="5"/&gt; 似乎没有效果
  • 当执行时间过长时,以下 javascript 似乎无法运行

       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);
          }
         });
    

这让我问这些问题

  1. 影响此代码执行的正确 IIS 设置和 .js 回调是什么?

  2. 当此应用程序扩展时,IIS 基础架构的哪些部分会受到压力?

  3. 如果 #2 变成基于 WAS 的 WCF 服务,是否会发生任何变化?

【问题讨论】:

    标签: asp.net wcf comet iis-7.5 reverse-ajax


    【解决方案1】:

    AsyncPostBackTimeout 的值的单位是秒,所以 5 表示 5 秒,当然我们不需要 5 秒来等待回调。 ExecutionTimeout 属性指示请求在被 ASP.NET 自动关闭之前允许执行的最大秒数。默认值为 110 秒。仅当元素中的调试属性设置为 false 时,此超时才适用。

    •当执行时间过长时,以下 javascript 似乎无法运行

    你怎么知道执行时间太长了?

    1.影响此代码执行的正确 IIS 设置和 .js 回调是什么?

    对于此示例,我们不需要在 IIS 中进行特殊设置。只有网络问题会导致执行超时。

    我很困惑您为什么要关注超时,您在使用我的示例时是否遇到了未处理的异常?

    Jerry Weng - MSFT

    【讨论】:

    • 感谢杰瑞的回复。我会检查一下debug=true 时会发生什么。我通过将模拟的Thread.Sleep 更改为 5 分钟来测试超时。我没有遇到任何超时,但我试图模拟如果服务器受到压力会发生什么。
    猜你喜欢
    • 2011-03-10
    • 2016-08-26
    • 1970-01-01
    • 2011-10-25
    • 2011-01-18
    • 2015-11-07
    • 2018-02-06
    • 1970-01-01
    • 2010-10-01
    相关资源
    最近更新 更多