tags:

views:

135

answers:

3

So somebody (ok it was me) didn't realize you need to close WCF proxies after using them.

How bad is this? What kind of problems can it cause.

Is there just a delay in closing resources because of garbage collection - or should I really worry about things like premature app pool recycling?

I actually have far more ASMX than WCF proxies with this issue - so the same question goes for ASMX also.

Obviously now that I know this I'm going to gradually fix it, but would appreciate input on how bad this really is?

+2  A: 

You can safely to reuse a WCF connection, just taking additional care to check if it's in a faulted state.

Rubens Farias
i wasn't even meaning reuse - just create, use and abandon - in most cases for every visit to a particular webpage
Simon_Weaver
+1  A: 

As a general guide when you are looking to gradually fix this, don't wrap your proxy's with a using statement, I've seen a lot of people do this, I was doing it until I read an article by IDesign that doing this might cause the Dispose to throw an exception and mask a real exception, explicitly close your proxy in try/catch, if close causes an exception, use Abort for resource clean up.

EDIT: As noted by the comment below this applies to WCF Proxies.

RandomNoob
This is only true for WCF proxies.
John Saunders
@john - you mean its ok to wrap ASMX proxies with a using statement?
Simon_Weaver
+4  A: 

A WCF service has a default timeout. If you do not close it, the service will wait until there is a timeout.

WCF also has a max concurrent calls, that has a default of 10.

Therefore, if you do not close your connections you can only have 10 calls per min. (assuming default settings)

Here is someone with a similar problem:

http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/d58ee1c6-032b-40f3-b734-6628f3991bb2/

Shiraz Bhaiji
do you know if the same is true for ASMX services. fortunately I discovered very early in my WCF lifecycle about this and can correct for it. its mostly ASMX that currently has this issue
Simon_Weaver
@simon the setting is a WCF config setting, so I do not think that it applies to ASMX.
Shiraz Bhaiji