Skip to content

Commit

Permalink
fix(compute/metadata): set IdleConnTimeout for http.Client
Browse files Browse the repository at this point in the history
This helps clean up idled connections held by the keep-alive.
The default transport set this to 90 seconds but since we
declare our own the default zero value means they are never
closed out if they are under the threshold for connections to
keep alive(2).

Fixes: googleapis#5430
  • Loading branch information
codyoss committed Nov 18, 2022
1 parent 22ec3e3 commit fe9024b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions compute/metadata/metadata.go
Expand Up @@ -70,6 +70,7 @@ func newDefaultHTTPClient() *http.Client {
Timeout: 2 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
IdleConnTimeout: 60 * time.Second,
},
Timeout: 5 * time.Second,
}
Expand Down

0 comments on commit fe9024b

Please sign in to comment.