Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
506 views
in Technique[技术] by (71.8m points)

wcf - 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" />

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

"
        }
    } 

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: http://blogs.msdn.com/b/silverlightws/archive/2010/12/15/pollingduplex-using-multiplemessagesperpoll-issue-in-latest-sl4-gdrs.aspx

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...