fix(region): google request retry

This commit is contained in:
ioito
2022-07-14 17:10:27 +08:00
parent 0928e67f11
commit 1ccee097ab
+8 -2
View File
@@ -22,6 +22,7 @@ import (
"net/http"
"net/url"
"strings"
"time"
"unicode"
"golang.org/x/oauth2"
@@ -891,6 +892,7 @@ func _jsonRequest(cli *http.Client, method httputils.THttpMethod, url string, bo
} else {
log.Errorf("%s %s error: %v", method, url, err)
}
retry := false
for _, msg := range []string{
"EOF",
"i/o timeout",
@@ -898,10 +900,14 @@ func _jsonRequest(cli *http.Client, method httputils.THttpMethod, url string, bo
"connection reset by peer",
} {
if strings.Index(err.Error(), msg) >= 0 {
continue
retry = true
break
}
}
return nil, err
if !retry {
return nil, err
}
time.Sleep(time.Second * 10)
}
return nil, err
}