From c7dc69bc67a8adaf1fd6b167d65d38fbdf0bba71 Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Thu, 17 May 2018 09:39:22 -0500 Subject: [PATCH] proxy: increase connection write timeout We don't know how much time a container can be paused, hence connection write timeout should be big enough to don't close the connection while the container is paused. fixes kata-containers/agent#231 fixes #70 Signed-off-by: Julio Montes --- proxy.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/proxy.go b/proxy.go index f733bd2..a1259ee 100644 --- a/proxy.go +++ b/proxy.go @@ -32,6 +32,8 @@ const ( termSignal = syscall.SIGTERM ) +const year time.Duration = time.Hour * 24 * 365 + var debug = false // version is the proxy version. This variable is populated at build time. @@ -43,7 +45,13 @@ var crashOnError = false var proxyLog = logrus.New() func serve(servConn io.ReadWriteCloser, proto, addr string, results chan error) (net.Listener, error) { - session, err := yamux.Client(servConn, nil) + sessionConfig := yamux.DefaultConfig() + sessionConfig.EnableKeepAlive = true + // 10 seconds is too early to suspect that a problem with the underlying connection has occurred. + // Since we don't know how much time a container can be paused let's set this timeout to 100 years, + // probably we won't be there when that occurs ;( + sessionConfig.ConnectionWriteTimeout = year * 100 + session, err := yamux.Client(servConn, sessionConfig) if err != nil { return nil, err }