SignalR/SignalR — Issue #168: Transports need to send "Keep Alives"
Author: ielbury
Created: 2012-01-31 21:06:58+00:00
State: open

In order to better support traversing network equipment that perform an kind of proxy function such as load balancers, UTM (Unified Thread Managment) appliances/software, proxy servers etc, a "keep alive" is required to keep the connection open.

Note also, that the "keep alive" is performed after the connection is **successfully** established and has no relevance to establishing a network connection and it's related failures. In the chat, there was reference to a 504 error. The 504 error is a failure for a network proxy to communicate with a web server and has nothing to do with maintaining a connection.

For streaming related transports, the keep alive is sent from the server. For example, In the case of SSE, it's a matter of sending a ':' character and could be implemented as part of the heart beat logic.

For long polling, the keep alive will have to be sent from the client and such it's configuration would need to be passed from the ConfigurationManager on the server to the client in the TransportData collection. A retriggerable timer on the send method would send a null packet (i am not sure what this is) on timeout and restart itself.

From an efficiency perspective ... specifically regarding mobile devices, there are two issues:

1. Data overhead
The question I have to as is what is the amount of data transmitted to make a connection? In my case, it about 1.7Kb not including TCP/IP overhead. My argument is that the keep alives (at least for SSE) cost 1 byte vs 1.7Kb. For a regular network connnection this is nothing but for a cell network, it adds up especially when you have data limits.

2. Battery
The battery life on mobile when using wireless is complex being that it is platform specific (iOS vs Android vs BB vs WM7 vs multi tasking vs psuedo muti tasking), radio specifc (Wifi vs Cell vs CDMA vs GSM vs LTE ). Battery is consumed when the radio is turned on. For WiFi, this is alll the time as it is constantly communicating with the base station. When on cell, the radio is **only** turned on when you transmit something and when it does may fall back to 2G speeds depending on it's algorithim. My argument is that it will likely (but may not) cost more to turn on the radio an transmit the 1.7Kb packet then it does to transmit a 1byte packet.

I realize that you guys disagree with me here, but am creating this issue because I feel strongly that this is an important discussion.