扩展微软的ASP.NET AJAX反向英寸长轮询" codePLEX例子 [英] Scaling Microsoft's ASP.NET Reverse AJAX "long poll" codeplex example

查看:292
本文介绍了扩展微软的ASP.NET AJAX反向英寸长轮询" codePLEX例子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在研究微软的反向AJAX样本其中,他们使用长超时在ScriptManager的

 < ASP:的ScriptManager ID =ScriptManager1=服务器AsyncPostBackTimeout =2147483647>

和一个ManualResetEvent的控制等待:

 私人的ManualResetEvent的MessageEvent =新的ManualResetEvent(假);
    公共信息DequeueMessage()
    {
        //等到一个新的消息。
        messageEvent.WaitOne();
    }
    公共无效EnqueueMessage(消息消息)
    {
        锁(的MessageQueue)
        {
            messageQueue.Enqueue(消息);            //设置一个新的消息的事件。
            messageEvent.Set();
        }
    }

我注意到


  • 设置AsyncPostBackTimeout为低值(5)不导致脚本超时或失败

  • <的httpRuntime executionTimeout =10/> 在web.config中似乎没有产生效果

  • 下面的JavaScript不会出现运行时的执行时间过长

      Sys.WebForms.PageRequestManager.getInstance().add_endRequest(功能(发件人,参数){
       如果(args.get_error()及与放大器; args.get_error()名称==='Sys.WebForms.PageRequestManagerTimeoutException'){
           警报('抓了超时!);
           //记得设置errorHandled = true来从AJAX库本身得到一个弹出保持
           args.set_errorHandled(真);
          }
         });


这让我问这些问题。


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


  2. 什么是IIS的基础设施部分时强调这个应用规模?


  3. 在是否#2改变任何东西,如果这成为一个WAS基于WCF服务?



解决方案

AsyncPostBackTimeout的值的单位是第二,所以5是指5秒,当然我们并不需要5秒钟,等待回调。
所述ExecutionTimeout属性表示的秒的请求被允许由ASP.NET被自动关闭之前执行的最大数量。默认为110秒。这个超时只适用于在元件中的调试属性被设置为假。


  

•下面的JavaScript不会出现运行时的执行时间过长


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


  

1.什么是影响这个code的执行正确的IIS设置和.js回调?


我们并不需要为这个样品在IIS中的特殊设置。只有网络问题可能会导致执行超时。

我很困惑,为什么你要专注于超时,弄来未处理的异常,当您使用我的样本?

杰里翁 - MSFT

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?

解决方案

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

这篇关于扩展微软的ASP.NET AJAX反向英寸长轮询&QUOT; codePLEX例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆