From 0d66f2c6d322fc7e8545bc3d9729e0e0f125754d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Sun, 27 Sep 2020 13:08:55 -0700 Subject: [PATCH] Tweak default HTTP client transport timeout values Reducing these values avoid going over the max number of file descriptors when refreshing lot of feeds --- http/client/client.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/http/client/client.go b/http/client/client.go index 177f1f44..fb416f72 100644 --- a/http/client/client.go +++ b/http/client/client.go @@ -237,7 +237,22 @@ func (c *Client) buildRequest(method string, body io.Reader) (*http.Request, err func (c *Client) buildClient() http.Client { client := http.Client{Timeout: time.Duration(config.Opts.HTTPClientTimeout()) * time.Second} - transport := &http.Transport{} + transport := &http.Transport{ + DialContext: (&net.Dialer{ + // Default is 30s. + Timeout: 10 * time.Second, + + // Default is 30s. + KeepAlive: 15 * time.Second, + }).DialContext, + + // Default is 100. + MaxIdleConns: 50, + + // Default is 90s. + IdleConnTimeout: 10 * time.Second, + } + if c.Insecure { transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} }