Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I ran into this problem this week and I wasn't able to quite figure out what was going on. I actually did change my call to my service to <code>Dispose()</code> the service client, but it didn't seem to have any effect. Apparently, there was another service call lurking somewhere.</p> <p>What may be interesting to note is what made me decide that this was <em>not</em> the problem: this limit is not related to the actual number of socket connections to the webservice. When you hit the <code>maxConcurrentSessions</code> limit, there is still only <strong>one actual socket connection</strong>. I was checking this with <code>netstat</code>, which brought me to the wrong conclusion. So, <strong>don't confuse sessions with sockets</strong>.</p> <p>We have interfaces defined for all our WCF services, so I'm planning to adapt this pattern in my code now:</p> <pre><code>IMyService service = new MyServiceClient(); using (service as IDisposable) { service.MyServiceMethod(); } </code></pre> <p>What's also interesting, is that the problem did not occur for me when the services (and website) were hosted on IIS. The configuration is (almost) identical, yet I could not reproduce this behavior on that machine. I guess that's a good thing :)</p> <h2>@ John Saunders (about variable assignment in <code>using</code>):</h2> <p>I usually do put the variable assignment in the <code>using</code> statement. But the IMyService that's generated is not implicitly convertible to <code>IDisposable</code>. If you really wanted the assignment in there, I suppose the alternative would be:</p> <pre><code>IService service; using ((service = new ServiceClient()) as IDisposable) { } </code></pre> <p>That still leaves the problem of the variable scope being wrong though. The reference to <code>IService service</code> is unusable, but still in scope. So this would be better in that respect:</p> <pre><code>using (IDisposable serviceDisposable = new ServiceClient()) { IService service = (IService)serviceDisposable; } </code></pre> <p>That requires me to introduce an extra variable name though. <strong>*Meh*</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload