diff --git a/ironmq.go b/ironmq.go index 1e29d7f..c17324c 100644 --- a/ironmq.go +++ b/ironmq.go @@ -76,23 +76,17 @@ func (c *Client) req(method, endpoint string, body []byte, data interface{}) err const maxRetries = 5 tries := uint(0) - eofCount := 0 var resp *http.Response for tries < maxRetries { resp, err = http.DefaultClient.Do(req) if err != nil { - if err == io.EOF && eofCount < 3 { - golog.Debugf("Retrying because of EOF %v\nPayload: %s\n", eofCount, body) - eofCount++ - req.Body = ioutil.NopCloser(bytes.NewBuffer(body)) - continue - } return err } // ELB sometimes returns this when load is increasing; we retry // with exponential backoff if resp.StatusCode == http.StatusServiceUnavailable { golog.Debugf("Retrying because of 503 %v\nPayload: %s\n", tries, body) + resp.Body.Close() tries++ // random delay between 0 and (4^tries*100) milliseconds pow := int64(1) << (2 * tries) * 100