WCF calls timing out
So I was building a prototype of a WCF service hosted in a windows service and everything seemed to be working fine, until I started calling the service with multiple clients. After 10 (successful) calls to the server, the server quit responding and any subsequent calls from the client would timeout.
As it turned out there were a couple of problems:
I was hitting the max concurrent sessions limit, which defaults to 10, after my session limit was hit the rest of the calls went in the bit bucket. So, of course I upped my session limit, and it fixed the problem temporarily until I hit the limit again. Then I realized that my client wasn't closing the session. I actually had a readline so I could verify the output, and at this point the session was still open. So I added a call to close the service proxy. If the readline had not been there the proxy would have gone out of scope, the session would have been closed automatically and I wouldn't have seen this problem. Also, if I had been using a non-sessionful channel such as BasicHttpBinding, I wouldn't have seen this. Oh well...
Things learned:
In the service behavior you can set (in serviceThrottling) -
MaxConcurrentCalls - this is the total number of simultaneous calls to process (default is 16)
MaxConcurrentSessions - total number of sessionful channels to accept (default is 10), this is disabled for non-sessionful channels such as BasicHttpBinding
MaxConcurrentInstances - total number of instance contexts created (default is Int32.MaxValue)
The purpose of these settings is to protect against DoS attacks.
Also, if you are using a sessionful channel, close it.
Labels: WCF

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home