【问题标题】:Silverlight PollingDuplex InnerChannel faulted with multipleMessagesPerPoll (serverPollTimeout)Silverlight PollingDuplex InnerChannel 出现 multipleMessagesPerPoll (serverPollTimeout) 故障
【发布时间】:2010-11-15 12:49:59
【问题描述】:

我正在运行 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 事件恰好在 one 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))

每个投票提琴手的单条消息表明,在每个serverPollTimeout 启动一个新的投票后,通道没有出现故障。

有什么想法吗?

编辑:

我已阅读 http://social.msdn.microsoft.com/Forums/en/wcf/thread/1e6aa407-4446-4d4a-8dac-5392250814b8http://forums.silverlight.net/forums/p/200659/468206.aspx#468206 我同意“singleMessagePerPoll”不是一个体面的解决方法。正如您在我的版本中看到的那样,我正在运行最新版本的 SDK 和开发人员运行时。

EDIT2:

我刚刚发现,如果我使用 google chrome 作为浏览器而不是 IE8 MultipleMessagesPerPoll 工作正常!对我来说,这闻起来像是运行时与 ie8 的错误?

EDIT3:

silverlight WS 博客上的确认: Link

【问题讨论】:

    标签: silverlight wcf pollingduplexhttpbinding


    【解决方案1】:

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

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

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

    要通过客户端堆栈执行所有 http 请求,请在开始服务调用之前使用它:

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

    不过,根据您的需要,您可以更具体一些。

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

    【讨论】:

    • 我们实际上能够通过 fiddler 在 chrome 中看到“MultipleMessagePerPoll”行为。
    • bug 仍然存在,但我们不需要 cookie 并且 ClientHttp 工作得很好
    【解决方案2】:

    此问题可能是由于将 global.asax 添加到托管网站造成的。将会话添加到托管站点显然会破坏 wcf 轮询双工服务。我在这个问题上苦苦挣扎了好几天,仅仅从主机网站上删除 global.asax 文件,服务中的挂起就消失了。 multiplemessagesperpoll 是一个错误的线索。它工作正常。

    查看更多:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-19
      • 1970-01-01
      • 1970-01-01
      • 2015-05-23
      • 2012-10-03
      • 2012-12-08
      • 2018-04-19
      • 1970-01-01
      相关资源
      最近更新 更多