From 86a3c731b77269621893c7fda9388f4499828ddf Mon Sep 17 00:00:00 2001 From: Alex Plischke Date: Tue, 24 Oct 2023 10:17:22 -0700 Subject: [PATCH] fix: terminate idle connections --- internal/http/webdriver.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/http/webdriver.go b/internal/http/webdriver.go index 2f5518ff6..70120891a 100644 --- a/internal/http/webdriver.go +++ b/internal/http/webdriver.go @@ -94,8 +94,14 @@ type sessionStartResponse struct { func NewWebdriver(url string, creds iam.Credentials, timeout time.Duration) Webdriver { return Webdriver{ HTTPClient: &http.Client{ - Timeout: timeout, - Transport: &http.Transport{Proxy: http.ProxyFromEnvironment}, + Timeout: timeout, + Transport: &http.Transport{ + Proxy: http.ProxyFromEnvironment, + // The server seems to terminate idle connections within 10 minutes, + // without any Keep-Alive information. We need to stay ahead of + // the server side disconnect. + IdleConnTimeout: 3 * time.Minute, + }, CheckRedirect: func(req *http.Request, via []*http.Request) error { // Sauce can queue up Job start requests for up to 10 minutes and sends redirects in the meantime to // keep the connection alive. A redirect is sent every 45 seconds.