From 0924e3719dff5e67c6928e963b66402c81ff3c95 Mon Sep 17 00:00:00 2001 From: gazebo Date: Sun, 5 Aug 2018 16:11:07 +0800 Subject: [PATCH] - try to fix EOF bug when accessing wenxi api. --- platformapi/platformapi.go | 2 +- platformapi/weixinapi/weixinapi.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/platformapi/platformapi.go b/platformapi/platformapi.go index 017c176a..e7c3a9a7 100644 --- a/platformapi/platformapi.go +++ b/platformapi/platformapi.go @@ -80,8 +80,8 @@ func AccessPlatformAPIWithRetry(client *http.Client, request *http.Request, conf if err != nil { baseapi.SugarLogger.Debugf("AccessPlatformAPIWithRetry client.Get return err:%v", err) err, ok := err.(net.Error) - recoverableErrorRetryCount++ if ok && err.Timeout() && recoverableErrorRetryCount <= config.MaxRecoverableRetryCount { + recoverableErrorRetryCount++ continue } else { baseapi.SugarLogger.Errorf("AccessPlatformAPIWithRetry access api request:%v, error:%v", request, err) diff --git a/platformapi/weixinapi/weixinapi.go b/platformapi/weixinapi/weixinapi.go index 8cff1d5c..abea8548 100644 --- a/platformapi/weixinapi/weixinapi.go +++ b/platformapi/weixinapi/weixinapi.go @@ -97,6 +97,7 @@ func (a *API) AccessAPI(action string, params map[string]interface{}, body strin } else { request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(body)) } + request.Close = true // todo try to fix EOF error when accessing weixin api. err = platformapi.AccessPlatformAPIWithRetry(a.client, request, a.config, func(response *http.Response) (result string, err error) { jsonResult1, err := utils.HTTPResponse2Json(response) if err != nil {