Use a custom http client when connecting to aws (#1945)
Signed-off-by: Christian Burke <cr0ax64@gmail.com>
This commit is contained in:
parent
0c64c988d5
commit
f4392a9e6f
@ -3,9 +3,11 @@ package storageproviders
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/core/playlist"
|
"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 {
|
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, "")
|
creds := credentials.NewStaticCredentials(s.s3AccessKey, s.s3Secret, "")
|
||||||
_, err := creds.Get()
|
_, err := creds.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -184,6 +194,7 @@ func (s *S3Storage) connectAWS() *session.Session {
|
|||||||
|
|
||||||
sess, err := session.NewSession(
|
sess, err := session.NewSession(
|
||||||
&aws.Config{
|
&aws.Config{
|
||||||
|
HTTPClient: httpClient,
|
||||||
Region: aws.String(s.s3Region),
|
Region: aws.String(s.s3Region),
|
||||||
Credentials: creds,
|
Credentials: creds,
|
||||||
Endpoint: aws.String(s.s3Endpoint),
|
Endpoint: aws.String(s.s3Endpoint),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user