WCF: Does Close () really close the connection?

We have some problems with WCF services and I'm doing some tests: I just created a new client and WCF service with default settings and keep track of how it works at the TCP level. I am using .net 4.0 and net.tcp .

And what I see: after using the operator, it closes WCF, doesn’t actually close the connection to the server ... At the TCP level, it should send the [FIN] packet to the server, but instead it does nothing, it just waits and after 2 minutes the server terminates the connection to the packet [RST]. I have added some screenshots from wirehark

I believe wcf works, but I could not find some information to confirm this. I also noticed that if after closing using the operator I open a new using statement, it uses the same port for communication on the client side ... (portsharing on the client is false)

My questions:

  • Why does WCF not close the connection to the server after using the closed statement?
  • What can I do to close it correctly (send [FIN])?

Thanks. postscript I don't bind any configs because these are the defaults that VS2010 creates for me.

wcf communication on tcp level

+4
source share
1 answer

Guess here, but netTcpBinding implements the connection cache . WCF will hang up with a TCP connection until some internal parameter / logic decides that it can be released. This is one of the reasons that the Dispose method can throw a "by design" exception.

{My 2 Β’: No matter how well the WCF designers streamlined this solution for themselves, in the real world, it was very dangerous.}

+1
source

Source: https://habr.com/ru/post/1393817/


All Articles