From f4392a9e6f2930b6a84495059c2f312f71e6a785 Mon Sep 17 00:00:00 2001 From: cr0ax <60494319+cr0ax@users.noreply.github.com> Date: Sat, 11 Jun 2022 18:21:11 -0700 Subject: [PATCH] Use a custom http client when connecting to aws (#1945) Signed-off-by: Christian Burke --- core/storageproviders/s3Storage.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/storageproviders/s3Storage.go b/core/storageproviders/s3Storage.go index 269dfdecd..09d82f871 100644 --- a/core/storageproviders/s3Storage.go +++ b/core/storageproviders/s3Storage.go @@ -3,9 +3,11 @@ package storageproviders import ( "bufio" "fmt" + "net/http" "os" "path/filepath" "strings" + "time" "github.com/owncast/owncast/core/data" "github.com/owncast/owncast/core/playlist" @@ -176,6 +178,14 @@ func (s *S3Storage) Save(filePath string, retryCount int) (string, error) { } func (s *S3Storage) connectAWS() *session.Session { + t := http.DefaultTransport.(*http.Transport).Clone() + t.MaxIdleConnsPerHost = 100 + + httpClient := &http.Client{ + Timeout: 10 * time.Second, + Transport: t, + } + creds := credentials.NewStaticCredentials(s.s3AccessKey, s.s3Secret, "") _, err := creds.Get() if err != nil { @@ -184,6 +194,7 @@ func (s *S3Storage) connectAWS() *session.Session { sess, err := session.NewSession( &aws.Config{ + HTTPClient: httpClient, Region: aws.String(s.s3Region), Credentials: creds, Endpoint: aws.String(s.s3Endpoint),