I am calling a WCF service from a form. Service is hosted in IIS. The service with the following attributes: InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple
I have set the throttling behaviour to max out at 2000 for all concurrent calls, instances and sessions.
However I cant seem to get more than 200 ASynch requests. After that the service just does not respond, and the session eventually times out.
I am using an Asynch call to call the method in the service ie Collapse | Copy Code
IASyncResult res= Proxy.BeginMethod(endCall,null);
and then to catch the response I have a endCall function that takes in the IASyncResult and processes the result via EndMethod().
in a load simulation @ 1 method call a second, it all works fine until around 200 calls, and then just waits... (I have 199 or 198 responses from those 200 calls at this point in time).. - so theoretically there should NOT be 200 concurrent sessions just 2 or so..
Perhaps there is some garbage collection or closing that I am not doing? any suggestions?
----update---
I think the answer maybe more that the closing of the proxy is not handled in a thread safe way. As Radik points out above, closing the proxy is important however with many IASyncState results coming in simultaneously you have to make sure you close the right one at the right time.
I did try firing off the close proxy from a thread to let it handle it seperately:
ThreadPool.QueueUserWorkItem(CloseProxy, ar.AsyncState);
but that does not seem to work. Any suggestions on this?