Skip to content

Commit

Permalink
Merge pull request #926 from imjaroiswebdev/issue-904-api-calls-cance…
Browse files Browse the repository at this point in the history
…l-by-timeout

Address: API calls cancelled by client because of Timeout
  • Loading branch information
imjaroiswebdev authored Aug 16, 2024
2 parents a944382 + 906fe59 commit 057058a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pagerduty/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ func (c *Config) Client() (*pagerduty.Client, error) {
httpClient.Timeout = 2 * time.Minute

transport := http.DefaultTransport.(*http.Transport).Clone()
// Set the maximum number of idle (keep-alive) connections across all hosts
// Experimenting with these values to see if it helps with the connection pool
// and hence to solve the issue
// https://github.com/PagerDuty/terraform-provider-pagerduty/issues/904
transport.MaxIdleConns = 0
transport.MaxIdleConnsPerHost = 500
transport.MaxConnsPerHost = 0

if c.InsecureTls {
transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
}
Expand Down Expand Up @@ -142,8 +150,17 @@ func (c *Config) SlackClient() (*pagerduty.Client, error) {

var httpClient *http.Client
httpClient = http.DefaultClient
httpClient.Timeout = 2 * time.Minute

transport := http.DefaultTransport.(*http.Transport).Clone()
// Set the maximum number of idle (keep-alive) connections across all hosts
// Experimenting with these values to see if it helps with the connection pool
// and hence to solve the issue
// https://github.com/PagerDuty/terraform-provider-pagerduty/issues/904
transport.MaxIdleConns = 0
transport.MaxIdleConnsPerHost = 500
transport.MaxConnsPerHost = 0

if c.InsecureTls {
transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
}
Expand Down
8 changes: 8 additions & 0 deletions pagerdutyplugin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ func (c *Config) Client(ctx context.Context) (*pagerduty.Client, error) {
httpClient.Timeout = 2 * time.Minute

transport := http.DefaultTransport.(*http.Transport).Clone()
// Set the maximum number of idle (keep-alive) connections across all hosts
// Experimenting with these values to see if it helps with the connection pool
// and hence to solve the issue
// https://github.com/PagerDuty/terraform-provider-pagerduty/issues/904
transport.MaxIdleConns = 0
transport.MaxIdleConnsPerHost = 500
transport.MaxConnsPerHost = 0

if c.InsecureTls {
transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
}
Expand Down

0 comments on commit 057058a

Please sign in to comment.