diff --git a/cluster/client/client.go b/cluster/client/client.go index 3eed947b..4b058cbe 100644 --- a/cluster/client/client.go +++ b/cluster/client/client.go @@ -369,10 +369,9 @@ func (c *APIClient) call(method, path, contentType string, data io.Reader, origi func (c *APIClient) request(req *http.Request) (int, io.ReadCloser, error) { if c.Client == nil { - tr := &http.Transport{ - MaxIdleConns: 10, - IdleConnTimeout: 30 * time.Second, - } + tr := http.DefaultTransport.(*http.Transport).Clone() + tr.MaxIdleConns = 10 + tr.IdleConnTimeout = 30 * time.Second c.Client = &http.Client{ Transport: tr, diff --git a/cluster/forwarder/forwarder.go b/cluster/forwarder/forwarder.go index a2be10ab..9d2a4389 100644 --- a/cluster/forwarder/forwarder.go +++ b/cluster/forwarder/forwarder.go @@ -65,10 +65,9 @@ func New(config ForwarderConfig) (Forwarder, error) { f.logger = log.New("") } - tr := &http.Transport{ - MaxIdleConns: 10, - IdleConnTimeout: 30 * time.Second, - } + tr := http.DefaultTransport.(*http.Transport).Clone() + tr.MaxIdleConns = 10 + tr.IdleConnTimeout = 30 * time.Second client := &http.Client{ Transport: tr, diff --git a/service/api/api.go b/service/api/api.go index 3afd02c5..fa47aa0f 100644 --- a/service/api/api.go +++ b/service/api/api.go @@ -53,12 +53,13 @@ func New(config Config) (API, error) { } if a.client == nil { + tr := http.DefaultTransport.(*http.Transport).Clone() + tr.MaxIdleConns = 10 + tr.IdleConnTimeout = 30 * time.Second + a.client = &http.Client{ - Transport: &http.Transport{ - MaxIdleConns: 10, - IdleConnTimeout: 30 * time.Second, - }, - Timeout: 5 * time.Second, + Transport: tr, + Timeout: 5 * time.Second, } } diff --git a/update/update.go b/update/update.go index 923f663e..25bceabf 100644 --- a/update/update.go +++ b/update/update.go @@ -147,12 +147,13 @@ func (s *checker) check() error { CoreViewer: uint64(metrics.Value("session_active", "collector", "hls").Val() + metrics.Value("session_active", "collector", "rtmp").Val()), } + tr := http.DefaultTransport.(*http.Transport).Clone() + tr.MaxIdleConns = 10 + tr.IdleConnTimeout = 30 * time.Second + client := &http.Client{ - Transport: &http.Transport{ - MaxIdleConns: 10, - IdleConnTimeout: 30 * time.Second, - }, - Timeout: 5 * time.Second, + Transport: tr, + Timeout: 5 * time.Second, } var data bytes.Buffer