Reputation: 2284
We have some issues with WCF services and I am doing some tests: I just created new WCF client and service with default settings and monitoring how it works on TCP level. I use .net 4.0 and net.tcp binding
And what I see: after using statement closes WCF does not really close connection to server... On TCP level it should send [FIN] package to server, but instead it do nothing, just waiting and in 2 minutes server terminate connection with [RST] package. I attached some screenshots from wireshark
I believe it's how wcf works, but I was not able to find some information to confirm it. Also I noticed than if after closing using statement, I open new using statement it use the same port to communicate on client side... (portsharing is false on client)
My questions:
Thanks. p.s. I am not attaching any configs, because it's default values which VS2010 creates for me.
Upvotes: 4
Views: 1982
Reputation: 12680
Guessing here but netTcpBinding does implement a connection cache. WCF will "hang on" to a TCP connection until some internal parameter/logic decides it can be released. That's one of the reasons that the Dispose method can throw an exception "by design".
{My 2¢: Regardless of how well the WCF designers rationalized by this decision to themselves, in the real world, it was a very dangerous thing to have done.}
Upvotes: 1