fix(region): aliyun request retry

This commit is contained in:
Qu Xuan
2021-02-23 11:48:45 +08:00
parent e0fd9e922f
commit 1c6d6c90f9
2 changed files with 6 additions and 1 deletions
+2 -1
View File
@@ -161,6 +161,7 @@ func jsonRequest(client *sdk.Client, domain, apiVersion, apiName string, params
"EOF",
"i/o timeout",
"TLS handshake timeout",
"Client.Timeout exceeded while awaiting headers",
"connection reset by peer",
"server misbehaving",
"SignatureNonceUsed",
@@ -229,7 +230,7 @@ func (self *SAliyunClient) getDefaultClient() (*sdk.Client, error) {
}
func (self *SAliyunClient) getSdkClient(regionId string) (*sdk.Client, error) {
transport := httputils.GetTransport(true)
transport := httputils.GetAdaptiveTransport(true)
transport.Proxy = self.cpcfg.ProxyFunc
client, err := sdk.NewClientWithOptions(
regionId,
+4
View File
@@ -301,6 +301,10 @@ func GetTransport(insecure bool) *http.Transport {
return getTransport(insecure, false)
}
func GetAdaptiveTransport(insecure bool) *http.Transport {
return getTransport(insecure, true)
}
func adptiveDial(ctx context.Context, network, addr string) (net.Conn, error) {
conn, err := net.DialTimeout(network, addr, 10*time.Second)
if err != nil {