Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF net.tcp connection dies after 9 hours, 1 minute

Tags:

wcf

I've got a WCF client talking to a WCF server (on the same machine). We use netTcpBinding with message-level security (using a custom principalPermissionMode and a custom implementation of serviceCredentials). The service is marked with InstanceContextMode.PerSession.

The WCF service is self-hosted in a Windows service (not in IIS).

In order to fake keep-alive, we have a Ping method that the client calls every 15 seconds. We keep the client proxy open for the lifetime of the client program (because initializing the session is expensive in our case).

Despite this, the connection is dropped after 9 hours, 1 minute and a bit (in 10 test runs, 7 of them died after 9h1m6s).

The only thing of consequence in the WCF logs is a "SocketConnection aborted" message, followed by a varying set of exceptions, but usually including a "connection was in the faulted state" exception.

Is there some timeout in WCF, or in TCP/IP, that's causing this? Because I'm stumped.

like image 742
Roger Lipscombe Avatar asked Nov 19 '10 10:11

Roger Lipscombe


2 Answers

After much tedious investigation: After about 9 hours, the WCF client re-authenticates with the service. Something I'm doing during the authentication step is killing the existing session.

like image 146
Roger Lipscombe Avatar answered Nov 03 '22 14:11

Roger Lipscombe


From your comments above you were running the tests at the same time.

Were they also on the same server, using the same application pool?

If so a recycling of the application pool could have caused all the tests to stop at the same time.

like image 21
Shiraz Bhaiji Avatar answered Nov 03 '22 14:11

Shiraz Bhaiji