开发者

Silverlight PollingDuplex InnerChannel faulted with multipleMessagesPerPoll (serverPollTimeout)

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


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:

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

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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜