我正在运行 silverlight 客户端版本 4.0.50917.0 和 SDK 版本 4.0.50826.1
我针对 wcf pollingduplex 绑定创建了一个简单的 silverlight 客户端:
网络配置:
<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" />
</system.serviceModel>
我的 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 事件时恰好在1 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 每个民意调查提琴手的单条消息表明,在每次serverPollTimeout
新的民意调查开始后并且通道没有故障。
有什么想法吗?
编辑:
我已阅读http://social.msdn.microsoft.com/Forums/en/wcf/thread/1e6aa407-4446-4d4a-8dac-5392250814b8和http://forums.silverlight.net/forums/p/200659/468206 .aspx#468206 并且我同意“singleMessagePerPoll”不是一个体面的解决方法。正如您在我的版本中看到的那样,我正在运行最新版本的 SDK 和开发人员运行时。
编辑2:
我刚刚发现,如果我使用 google chrome 作为浏览器而不是 IE8 MultipleMessagesPerPoll 工作正常!对我来说,这闻起来像是运行时与 ie8 的错误?
编辑3:
Silverlight WS 博客上的确认: 链接