mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: prevent idle connections leaking FDs
Patch from af6ada910f
Without this change, if a long-lived process uses the client and creates
connections, these connections are not released and grow over time.
We can also look into addressing this issue from the server side, but it
doesn't hurt for the `client` package to have good defaults and not
cause this.
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
This commit is contained in:
@@ -247,6 +247,14 @@ func (cli *Client) tlsConfig() *tls.Config {
|
||||
|
||||
func defaultHTTPClient(hostURL *url.URL) (*http.Client, error) {
|
||||
transport := &http.Transport{}
|
||||
// Necessary to prevent long-lived processes using the
|
||||
// client from leaking connections due to idle connections
|
||||
// not being released.
|
||||
// TODO: see if we can also address this from the server side,
|
||||
// or in go-connections.
|
||||
// see: https://github.com/moby/moby/issues/45539
|
||||
transport.MaxIdleConns = 6
|
||||
transport.IdleConnTimeout = 30 * time.Second
|
||||
err := sockets.ConfigureTransport(transport, hostURL.Scheme, hostURL.Host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user