From cc2a1d12043c5c09f3ecdfeedae33564d317b3b1 Mon Sep 17 00:00:00 2001 From: Rueian Date: Tue, 17 Dec 2019 09:02:28 +0800 Subject: [PATCH] bug(cloudflared): Set the MaxIdleConnsPerHost of http.Transport to proxy-keepalive-connections (#155) Setting the MaxIdleConns is not enough, the MaxIdleConnsPerHost must be set as well. Otherwise, http.Transport will use the DefaultMaxIdleConnsPerHost, which is 2, and then the connection pool will have only 2 connection hold. --- cmd/cloudflared/tunnel/configuration.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/cloudflared/tunnel/configuration.go b/cmd/cloudflared/tunnel/configuration.go index ef24751b..c746a585 100644 --- a/cmd/cloudflared/tunnel/configuration.go +++ b/cmd/cloudflared/tunnel/configuration.go @@ -197,6 +197,7 @@ func prepareTunnelConfig( httpTransport := &http.Transport{ Proxy: http.ProxyFromEnvironment, MaxIdleConns: c.Int("proxy-keepalive-connections"), + MaxIdleConnsPerHost: c.Int("proxy-keepalive-connections"), IdleConnTimeout: c.Duration("proxy-keepalive-timeout"), TLSHandshakeTimeout: c.Duration("proxy-tls-timeout"), ExpectContinueTimeout: 1 * time.Second,