WCF Keep Alive Channel

Customers periodically ask for a way to enable TCP Keep Alive on the underlying socket for the TCP transport in WCF.  The most often reason I hear this request is to workaround an idle timeout on some intermediary device (like a proxy or load balancer).  However, TCP Keep alive is a hop by hop solution that will usually only solve the problem for the connection between the client and the first intermediary device on the network.  If there are multiple intermediary devices between the client and server, then TCP Keep alive probably won’t solve the problem. 

One team here at Microsoft solved this problem by implementing a KeepAlive WCF Layered channel that sends application-transparent soap messages as necessary to keep the channel alive.  The code was tested quite heavily by the team that implemented it and they agreed to allow us to publish it for others to use.  If you are interested, you can find the code at http://code.msdn.microsoft.com/WCF-Azure-NetTCP-Keep-Alive-09f50fd9.

Comments (1)

  1. Jon says:

    Have you got any sources that show that TCP Keep Alive is a hop by hop solution? If a packet is sent why would a hop not send it on? Is it tracking sequence numbers? Or is it because it may* contain no data?

    * Windows has a garbage octet as payload, Linux has 0 size payload.

Skip to main content