From c2e7d663bcb0992da7b29795bd9118c87a890850 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Tue, 15 Mar 2022 13:32:05 +0500 Subject: [PATCH] reduced the timeout for creating a connection from 30 to 10 seconds --- weed/operation/upload_content.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go index 569a54372..3d41d2eb5 100644 --- a/weed/operation/upload_content.go +++ b/weed/operation/upload_content.go @@ -11,6 +11,7 @@ import ( "io" "mime" "mime/multipart" + "net" "net/http" "net/textproto" "path/filepath" @@ -65,6 +66,10 @@ var ( func init() { HttpClient = &http.Client{Transport: &http.Transport{ + DialContext: (&net.Dialer{ + Timeout: 10 * time.Second, + KeepAlive: 10 * time.Second, + }).DialContext, MaxIdleConns: 1024, MaxIdleConnsPerHost: 1024, }} @@ -261,6 +266,7 @@ func upload_content(fillBufferFunction func(w io.Writer) error, originalDataSize if post_err != nil { if strings.Contains(post_err.Error(), "connection reset by peer") || strings.Contains(post_err.Error(), "use of closed network connection") { + glog.V(1).Infof("repeat error upload request %s: %v", option.UploadUrl, postErr) resp, post_err = HttpClient.Do(req) } }