Silverlight PollingDuplex InnerChannel 出现 multipleMessagesPerPoll (serverPollTimeout) 故障
我正在运行 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))
又名每个轮询的一条消息,fiddler 会显示在每个 serverPollTimeout
后,都会启动一个新的轮询,并且通道不< /em> 出错了。
有什么想法这里出了什么问题吗?
编辑:
我已阅读 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 博客上确认: 链接< /a>
Im running silverlight client version 4.0.50917.0 and SDK version 4.0.50826.1
I've created a simple silverlight client against a wcf pollingduplex binding:
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" />
</system.serviceModel>
My silverlight client connect like this:
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))
I got an eventhandler for innerchannel faulted:
client.InnerChannel.Faulted += new EventHandler(InnerChannel_Faulted);
...
void InnerChannel_Faulted(object sender, EventArgs e)
{
Dispatcher.BeginInvoke(() =>
{ status.Text += "Inner channel Faulted\n\n"
}
}
When using the above the Client.InnerChannelFaulted event happens exactly after one serverPollTimeout
. (default 15seconds, verified with Fiddler)
If I switch my client to connect like this:
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 single message per poll fiddler reveals that after each serverPollTimeout
a new poll is started and the channel is not faulted.
Any ideas what's wrong here?
EDIT:
I have read http://social.msdn.microsoft.com/Forums/en/wcf/thread/1e6aa407-4446-4d4a-8dac-5392250814b8 and http://forums.silverlight.net/forums/p/200659/468206.aspx#468206
and I agree that "singleMessagePerPoll" is not a decent workaround. As you can see on my versions I am running the most recent versions of SDK and developer runtime.
EDIT2:
I just found out, that if I use google chrome as browser instead of IE8 MultipleMessagesPerPoll works fine! To me this smells like a runtime vs. ie8 bug?
EDIT3:
An confirmed on the silverlight WS blog:
Link
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在具有相同 SDK 和客户端版本的示例上确认了该问题。
这个问题对其他浏览器也有一些更多的影响:我的印象是 MultipleMessagePerPoll 似乎在它们上也不能正常工作(Fiddler 和 Firebug 显示了一些看起来很像 SingleMessagePerPoll 的东西)
但是我可以通过使用客户端网络堆栈(绕过浏览器网络堆栈)。然而,这个解决方案远非完美,因为在这种情况下必须手动设置 cookie。它可能很烦人,也可能不是问题,具体取决于您的应用程序。
要通过客户端堆栈执行所有 http 请求,请在开始服务调用之前使用它:
但是,根据您的需要,您可以更具体一些。
如果有人有更满意的答案,我很乐意阅读。如果您有兴趣重现该问题,我已修改了旧的 Tomek 示例,以在 SL4 上使用 MultipleMessagePerPoll,而不是在 SL3 上使用 SingleMessagePerPoll。
I confirm the issue on a sample, with the same SDK and client versions.
The issue has some more implications on other browsers too: I am under the impression that MultipleMessagePerPoll doesn't seem to work correctly on them neither (Fiddler and Firebug show something which looks a lot like SingleMessagePerPoll)
However I could make it work by using the client Network stack (bypassing the browser network stack). This solution is however far from perfect, as cookies must be set manually in this case. It can can be annoying or a non-issue depending on your application.
To perform all http request through the client stack, use this before you start your service calls:
You could however be a little more specific, according to your needs.
If someone has a more satisfying answer, I would be glad to read it. If you are interested in reproducing the probleme, I have modified an old Tomek sample to use MultipleMessagePerPoll on SL4 instead of SingleMessagePerPoll on SL3.
此问题可能是由于将 global.asax 添加到托管网站而引起的。将会话添加到托管站点显然会搞砸 wcf 轮询双工服务。我为这个问题苦苦挣扎了好几天,仅仅通过从主机网站删除 global.asax 文件,服务挂起就消失了。每次民意调查的多重消息是一个错误的线索。效果很好。
有关更多信息,请参阅此:
新添加的 global.asax 文件如何弄乱我的 WCF 服务
This problem can be caused by adding global.asax to the hosting web site. Adding sessions to the hosting site apparently screws up the wcf polling duplex service. I struggled with this issue for several days and by merely deleting the global.asax file from the host web site the hang in the service went away. The multiplemessagesperpoll was a false lead. It works fine.
See this for more:
How can a newly added global.asax file make a mess of my WCF service