tags:

views:

100

answers:

2

I am maintaing a Windows Forms application using WCF and are using Net.TCP internally. The lifecycle of our connections is GET/USE/CLOSE.

We are having a problem with the application pool crashing with no trace. In looking at netstat, I can see when I come into the application as we have a login service. However, even though we are creating the proxy in a using statement, the connection in netstat does not go away until I physically close the application.

Is this right? Should I be doing something different on the client to force the connection to close?

So if the connection stays open, does it stay open for the duration of the openTimeout setting and then gets torn down?

A: 

First, you should probably not being using your proxy within the context of a using statement even though is does implement IDisposable: http://stevesmithblog.com/blog/idisposable-and-wcf/

That being said, it all depends on how you are utilizing the proxy. Take a look at marc's response here: http://stackoverflow.com/questions/1920583/c-wcf-when-to-reuse-a-client-side-proxy

MattK
Matt, thanks for the links to Steve's blog. There were further links there to MSDN which shed more light on the situation. This information will be very helpful to us as we try to solve this.One additonal question. What determines how many connections are open to the service? If we have several client apps hitting one service and if one of them has a lower number than the other, and the one with the lower number hits first, is that number the high water mark for connections, or is it by client?Thanks.
MikeMalter
A: 

Yes, that's the expected behavior: the Net.TCP binding has a protocol-level transport session with your server, something you cannot really control in WCF.

I don't know of any mechanism in WCF to physically tear down that transport-level session - you might be able to do that using low-level TCP calls, but I've never had the need to do anything like that.

marc_s