我正在运行silverlight客户端版本4.0.50917.0和SDK版本4.0.50826.1
我已经针对wcf轮询双工绑定创建了一个简单的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))也就是每个投票摆弄者的单条消息显示,在每个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和developer运行时。
EDIT2:
我刚刚发现,如果我用google作为浏览器而不是IE8 MultipleMessagesPerPoll,那就可以了!对我来说,这闻起来像一个运行时和ie8的bug?
EDIT3:
silverlight WS博客上的确认:链接
发布于 2010-11-20 13:25:55
使用相同的SDK和客户端版本,我在示例中确认了这个问题。
这个问题在其他浏览器上也有更多的含义:我的印象是MultipleMessagePerPoll似乎也没有在它们上正确工作(Fiddler和Firebug显示了一些看起来很像SingleMessagePerPoll的东西)
但是,我可以通过使用客户端网络堆栈(绕过浏览器网络堆栈)来使其工作。然而,这个解决方案远非完美,因为在这种情况下,必须手动设置cookie。它可以是烦人的,也可以是没有问题的,取决于您的应用程序。
若要通过客户端堆栈执行所有http请求,请在启动服务调用之前使用该请求:
HttpWebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);但是,根据您的需要,您可以更具体一些。
如果有人有一个更令人满意的答案,我会很高兴看到它。如果您有兴趣复制问题,我已经修改了一个旧的Tomek示例,在SL4上使用SingleMessagePerPoll而不是SL3上的SingleMessagePerPoll。
发布于 2014-02-15 12:07:28
将global.asax添加到宿主网站可能会导致此问题。将会话添加到托管站点显然会破坏wcf轮询双工服务。我在这个问题上挣扎了好几天,仅仅从主机网站上删除了global.asax文件,服务中的挂起就消失了。这次多次投票是错误的结果。效果很好。
有关更多信息,请参见:
https://stackoverflow.com/questions/4184469
复制相似问题