Wednesday, September 12, 2007

WCF timeout exception

I know I said WCF is not well documented, and I still believe it but I must say that when I posted about this issue I got a guy from Microsoft (named Richie) who really stuck with me to help me solve the problem. Even though I solved it, I still don't understand why. Now I'll post about it (and the solution) so hopefully I will help somebody with it and maybe some one can explain to me why the generated code with svcutil does not have what I want.

It all started implementing security features in the DeKlarit WCF Addin. When I finally got it working I started testing, and at some point the server did not respond and the client exited with a TimeoutException. I added trace log and message log and noticed that it always felt on the 15th communication.

After going thru the Indigo forum and Googled around I found the problem is due to the amount of concurrent connections opened and the timeout the have by default. What?!. Well, that's exactly what I thought, at least the NetTcpBinding (the one I'm using right now) has a default configuration that works in some limited cases.

How did I solve it? Closing the base channel every time so the connections won't add up. Even though it's been fixed I still don't understand why the generated code by the svcutil does not have those "close" calls.

Somebody? Anybody?

6 comments:

Anonymous said...

Hey have u found the reason for the problem? i am using wsHttpBinding

Sebastian said...

No, all I know it is still working closing the channels as I mentioned

alone said...

How did you close the Base Channel?
I'm having the same problem as you had.

Thank you.

Sebastian said...

in your proxy call base.channel.close();

It is a good practice to make your client proxy Disposable and write the above line in the Dispose() method.

Golda said...

Is this WCF single-instance/multi-threaded? I think we had this issue when we had multiple instances of the WCF, but not with single-instance.

Sebastian said...

Nice tip Golda. Actually I´m not sure about that.

In any case it is a good practice to always close your channels