- try to fix EOF bug when accessing wenxi api.

This commit is contained in:
gazebo
2018-08-05 16:11:07 +08:00
parent af1155e415
commit 0924e3719d
2 changed files with 2 additions and 1 deletions

View File

@@ -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)

View File

@@ -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 {