veyron/lib/websocket|veyron/runtimes/google/ipc: Set KeepAlive in Dialers and Listeners
On some systems, GCE in particular, inactive connections can get
blackholed, which means that readers never see EOF even when the other
side is done. The same problem happens when either end of a connection
dies and the TCP FIN or RST packet doesn't reach the other end.
The general solution to this problem is to set the KeepAlive option on
all TCP connections. For clients, we need to set the KeepAlive field
on net.Dialer. For servers, we need to call SetKeepAlive() and
SetKeepAlivePeriod() on TCPConn objects.
The previous code attempted to catch all cases at the VIF level, but
with the wide variety of net.Conn implementations that we have now, and
all the future ones that we will probably have in the future, it is
better to set the KeepAlive option in the Dialer and Listeners of each
protocol instead.
The GO team did something very similar, but only in http.ListenAndServe.
They expect everyone with more complicated use-cases to know what
they're doing and set KeepAlive correctly themselves.
For reference:
https://groups.google.com/forum/#!topic/golang-dev/zh6frmUA8no
https://developers.google.com/compute/docs/troubleshooting#communicatewithinternet
Change-Id: Ifd5b798e13818772cebb0f0f965e1a26bd5ddfb6
6 files changed