WCF Channel: Server not responding after 10 minutes

1.4k views Asked by At

I created an architecture formed by a client and a server those communicates on a WCF Channel in localhost, all works fine, but if there is no activity (requests from client) between the two ones for more than 10 minutes the server doesn't respond anymore. The connection is still alive but simply server is not responding to client request, so the client must disconnect and reconnect for being able to send request to the server. Maybe I let some parameters slip.

The address I used is: net.tcp://localhost:8080/ICS; Channel type: duplex;

2

There are 2 answers

4
Johnny On BEST ANSWER

The problem here is in receiveTimeout. The service host uses this timeout to determine when to drop idle connections. If no message is received within the configured time span the connection is closed. By default it is 10 minutes.

0
fondente On

Update, ReliableMessaging is not enabled therefore edit InactivityTimeout makes no sense

Whereas changing ReceiveTimeout parameter of my binding settings solves the problem.

My code:

var bind = new NetTcpBinding();                   // my binding instance
var relSessionEnabled = bind.ReliableSession.Enabled;            // this is false
var inactivityTimeout = bind.ReliableSession.InactivityTimeout;  // this is 10 minutes
bind.ReceiveTimeout = TimeSpan.MaxValue;          // this was 10 minutes before this instructuion