PollingDuplexHttpBinding, Silverlight4, and a MaxSessionsPerAddress throttle

Unanswered PollingDuplexHttpBinding, Silverlight4, and a MaxSessionsPerAddress throttle

  • Tuesday, August 09, 2011 4:10 PM
     
      Has Code

    I've got a self-hosted WCF service that uses the PollingDuplexHttpBinding that I'm trying to load test.  The service is hosted in a WPF app (for test, Windows Service for production), and everything works as expected under normal circumstances.  I've created a simple load test client to try to simulate a large number of clients connecting to the service and requesting data.  This client is just a SL4 app that starts N threads, and has each thread create a proxy and invoke a service method at the same time.  This works fine for up to 10 threads, but if I increase past this, I start getting exceptions saying that the service is too busy.  Here's the code I use to wire up the service host and create my singleton service instance:

     

          PollingDuplexHttpBinding b;
          b = new PollingDuplexHttpBinding(PollingDuplexHttpSecurityMode.TransportWithMessageCredential, System.ServiceModel.Channels.PollingDuplexMode.MultipleMessagesPerPoll);
          b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Digest;
        
          iceService = new iceWCFService.iceService();
          Uri baseAddress = new Uri(ServiceAddress);
          iceServiceHost = new ServiceHost(iceService, baseAddress);
        
          //make sure that the binding isn't throttled at all-this should be tuned down to the *real* maximum later on
          ServiceThrottlingBehavior tb = new ServiceThrottlingBehavior();
          tb.MaxConcurrentCalls = Int32.MaxValue;
          tb.MaxConcurrentSessions = Int32.MaxValue;
          tb.MaxConcurrentInstances = Int32.MaxValue;
          iceServiceHost.Description.Behaviors.Add(tb);
    
          //include exception detail in faults for the test host:
          ServiceDebugBehavior debug = iceServiceHost.Description.Behaviors.Find<ServiceDebugBehavior>();
          // if not found - add behavior with setting turned on 
          if (debug == null)
            iceServiceHost.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });
          else
            debug.IncludeExceptionDetailInFaults = true;
    
          b.UseTextEncoding = false;
          b.MaxReceivedMessageSize = long.MaxValue; //should probably make this a real max sometime...
          iceServiceHost.AddServiceEndpoint(typeof(iceWCFService.IiceService), b, baseAddress);
    

     


    I enabled tracing on the service, and I found this in the scvlog:

    "The server has hit a PollingDuplex throttle, MaxSessionsPerAddress, and cannot accept another session from this client. An http error was returned."

    As you can see in the code, I've set the max concurrent calls and sessions for the host, but I haven't found any references to this throttling setting other than a blog post that Yavor made last year (that mentions the throttling, but not how to change it.

    So, is there any way to get more than 10 connections from a single host?  If I run my load test in 2 different browsers and start 10 threads on each (at the same time) they all succeed, but make that 11 threads on each, and one on each browser fails.  This is definitely the setting that's throttling me, and I'd really like to change it.  Any suggestions on how to get it to work? 

     

All Replies

  • Thursday, August 11, 2011 1:15 AM
    Moderator
     
     
    Hello, this is by design. You can't increase MaxSessionsPerAddress. But you don't need to worry about this issue. You're hitting this issue because you're trying to simulate too many clients in the same browser session. As you've found, if you open two different browser sessions, you can create up to 10 threads in each session. So you should change the way you do load test. Instead of simulate too many clients in the same browser session, you should create multiple browser sessions. If you can use multiple machines, it will be even better. In real world scenario, you won't hit this issue, since it's unlikely that a client needs to open more than 10 concurrent sessions to a single duplex service.
    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    Windows Azure Technical Forum Support Team Blog
  • Monday, August 15, 2011 6:35 PM
     
     
    Actually, I have seen this happen with a client application that needs to pull a lot of data from the service on startup.  This means that the client needs to be reworked to make sure that this doesn't happen.  While I'd like to see this be configurable (like the other throttles), it'd be nice if the setting was better documented, since I wasn't able to find any references to it the documentation (and the fact that it's not configurable).