代码之家  ›  专栏  ›  技术社区  ›  svrist

Silverlight PollingDuplex InnerChannel出现故障,出现多个MessagesPerPoll(serverPollTimeout)

  •  4
  • svrist  · 技术社区  · 15 年前

    Im运行silverlight客户端版本4.0.50917.0和SDK版本4.0.50826.1

    我针对wcf pollingduplex绑定创建了一个简单的silverlight客户端:

    Web.config:

    <system.serviceModel>
    <extensions>
      <bindingExtensions>
        <add name="pollingDuplexHttpBinding"
            type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </bindingExtensions>
    </extensions>
    <behaviors>
      <serviceBehaviors>
        <behavior name="sv">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceThrottling maxConcurrentSessions="2147483647"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    
    <bindings>
      <!-- Create the polling duplex binding. -->
      <pollingDuplexHttpBinding>
        <binding name="multipleMessagesPerPollPollingDuplexHttpBinding"
                 duplexMode="MultipleMessagesPerPoll"
                 maxOutputDelay="00:00:01"/>
    
        <binding name="singleMessagePerPollPollingDuplexHttpBinding"
                 maxOutputDelay="00:00:01"/>
      </pollingDuplexHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="sv" name="Backend.GUIPollingService">
        <endpoint address="" binding="pollingDuplexHttpBinding" bindingConfiguration="singleMessagePerPollPollingDuplexHttpBinding"
          contract="Backend.IGUIPollingService" />
        <endpoint address="mmpp" binding="pollingDuplexHttpBinding" bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
          name="multimessage" contract="Backend.IGUIPollingService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    

    我的silverlight客户端连接如下:

     string endPointAddress2 = "http://"
              + App.Current.Host.Source.DnsSafeHost
              + ":"
              + App.Current.Host.Source.Port.ToString(CultureInfo.InvariantCulture)
              + "/GUIPollingService.svc/mmpp";
     this.client = new GUIClientProxy.GUIPollingServiceClient(
            new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll), 
            new EndpointAddress(endPointAddress2))
    

    我有一个内部通道故障的事件处理程序:

    client.InnerChannel.Faulted += new EventHandler(InnerChannel_Faulted);
    

    ...

    void InnerChannel_Faulted(object sender, EventArgs e)
        {
    
            Dispatcher.BeginInvoke(() =>
            { status.Text += "Inner channel Faulted\n\n"
            }
        } 
    

    当使用上面的Client.InnerChannelFaulted事件正好发生在 serverPollTimeout . (默认15秒,用Fiddler验证)

    如果我将我的客户端切换为这样的连接:

    string endPointAddress2 = "http://"
              + App.Current.Host.Source.DnsSafeHost
              + ":"
              + App.Current.Host.Source.Port.ToString(CultureInfo.InvariantCulture)
              + "/GUIPollingService.svc";
     this.client = new GUIClientProxy.GUIPollingServiceClient(
            new PollingDuplexHttpBinding(), 
            new EndpointAddress(endPointAddress2))
    

    每个投票的aka单个消息fiddler显示 服务器轮询超时 开始新的投票,频道 出现故障。

    有什么问题吗?

    编辑:

    我读过 http://social.msdn.microsoft.com/Forums/en/wcf/thread/1e6aa407-4446-4d4a-8dac-5392250814b8 http://forums.silverlight.net/forums/p/200659/468206.aspx#468206 我也同意“单条消息投票”不是一个体面的解决办法。正如您在我的版本中看到的,我运行的是最新版本的SDK和developer runtime。

    编辑2:

    我刚刚发现,如果我使用谷歌浏览器而不是IE8多消息浏览器可以很好的工作!对我来说这闻起来像是一个运行时对ie8的错误?

    编辑3:

    silverlight WS博客上的确认消息: http://blogs.msdn.com/b/silverlightws/archive/2010/12/15/pollingduplex-using-multiplemessagesperpoll-issue-in-latest-sl4-gdrs.aspx

    2 回复  |  直到 15 年前
        1
  •  3
  •   Eilistraee    15 年前

    我用相同的SDK和客户端版本在一个示例上确认了这个问题。

    这个问题对其他浏览器也有更多的影响:我的印象是MultipleMessagePerPoll似乎也不能在它们上正常工作(Fiddler和Firebug显示了一些很像SingleMessagePerPoll的东西)

    不过,我可以通过使用客户端网络堆栈(绕过浏览器网络堆栈)使其工作。然而,这个解决方案还远远不够完美,因为在这种情况下必须手动设置cookies。根据您的应用程序的不同,它可能是烦人的,也可能是没有问题的。

    要通过客户端堆栈执行所有http请求,请在启动服务调用之前使用此命令:

    HttpWebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
    

    不过,根据你的需要,你可以更具体一点。

    如果有人有一个更令人满意的答案,我很乐意阅读。如果您有兴趣重现这个问题,我修改了一个旧的Tomek示例,在SL4上使用MultipleMessagePerPoll,而不是在SL3上使用SingleMessagePerPoll。

        2
  •  1
  •   Community Mohan Dere    9 年前

    将global.asax添加到宿主网站可能会导致此问题。向宿主站点添加会话显然会破坏wcf轮询双工服务。我在这个问题上挣扎了好几天,仅仅从宿主网站上删除global.asax文件,服务中的挂起就消失了。多因素调查是一个错误的线索。它工作得很好。

    更多信息请参见:

    How can a newly added global.asax file make a mess of my WCF service

    推荐文章