title: WCF Throttling and Connection Limits
body: <p>I have browsed the internet and stack overflow for answers but I can't seem to get a clear answer to my issues.</p>
  
  <p>I have around 50 clients spread out across the country that regularly open up a WCF WSHTTPBinding call automatically through a Windows service to the server every 10-20 mins.  This works well because I limit the # of clients that can connect and perform long running operations through the server and the client then knows it cannot do anything and tries the next time it checks back in.</p>
  
  <p>This has been working well until yesterday when one client that has 7 separate systems behind the same router started having very very slow internet issues.  So those 7 systems would open up a connection to the server every 10-20 mins, and perform their "check-in" procedures.  The calls would take a while and each system may be connected to the service at once using up 7 connections to the server.  The other 43 systems also need to "check-in" as well every 10-20 minutes.  But since the client with 7 systems was having slow internet, the calls to the long running processes on the serice were taking longer than normal and eventually timing out on the client (I even got stale security timestamp errors sometimes).  This in return would occasionally hang the WCF service from responding to any other client requests and then eventually the client would timeout and the server connections would clean up and process other requests.</p>
  
  <p>I need my service to be completely unaffected by client internet issues and the service needs to keep chugging along servicing the other clients that continue to "check-in".</p>
  
  <p>Now, I've implemented Service Throttling Behavior on the service end already:</p>
  
  <pre><code>Dim stb As New ServiceThrottlingBehavior
  stb.MaxConcurrentSessions = 100
  stb.MaxConcurrentCalls = 20
  stb.MaxConcurrentInstances = 120
  
  serviceHost.Description.Behaviors.Add(stb)
  </code></pre>
  
  <p>I've done some reading out there and found this setting, but do not have this in my code as of now:</p>
  
  <pre><code>System.Net.ServicePointManager.DefaultConnectionLimit
  </code></pre>
  
  <p>Which I've tried to understand but don't entirely.  So, now with my explanation, here are my questions:</p>
  
  <ul>
  <li>Do I set System.Net.ServicePointManager.DefaultConnectionLimit at the service or client end?
  <li>Where would I set that?  Before I open the ServiceHost?  Before I create the ServiceHost?
  <li>Are there any other areas to change for connection limits and concurrent calls for WCF?  (It seems from my reading there can be a few, depending on what binding you're using)
  </ul>
  
  <p>Note: If you post answers, please use code, I do not use the config file for my bindings, I create my binding programmatically.</p>
  
  <p>Thank you.</p>