我已经针对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))
我为innerchannel故障得到了一个事件处理程序:
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))
每个轮询fiddler也称单个消息显示在每个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和开发人员运行时.
EDIT2:
我刚刚发现,如果我使用谷歌浏览器作为浏览器而不是ie8 MultipleMessagesPerPoll工作正常!对我来说,这闻起来像运行时与ie8的错误?
EDIT3:
在Silverlight WS博客上确认:
http://blogs.msdn.com/b/silverlightws/archive/2010/12/15/pollingduplex-using-multiplemessagesperpoll-issue-in-latest-sl4-gdrs.aspx
这个问题对其他浏览器也有一些影响:我认为MultipleMessagePerPoll似乎也不能正常工作(fiddler和FireBUG显示的东西看起来很像SingleMessagePerPoll)
但是,我可以通过使用客户端网络堆栈(绕过浏览器网络堆栈)使其工作.然而,这种解决方案远非完美,因为在这种情况下必须手动设置cookie.根据您的应用,它可能会令人烦恼或无问题.
要通过客户端堆栈执行所有http请求,请在开始服务调用之前使用此请求:
httpWebRequest.RegisterPrefix("http://",WebRequestCreator.ClIEnthttp);
然而,根据您的需要,您可以更具体一点.
如果有人有更满意的答案,我会很高兴看到它.如果你有兴趣重现这个问题,我修改了一个旧的Tomek示例,在SL4上使用MultipleMessagePerPoll而不是SL3上的SingleMessagePerPoll.
总结以上是内存溢出为你收集整理的Silverlight PollingDuplex InnerChannel与multipleMessagesPerPoll(serverPollTimeout)出现故障全部内容,希望文章能够帮你解决Silverlight PollingDuplex InnerChannel与multipleMessagesPerPoll(serverPollTimeout)出现故障所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)