Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Work around EOF errors

See Go issue: http://code.google.com/p/go/issues/detail?id=3514

This solution is kind of racy since we're not guaranteed to be using the
same connection again when we retry, but it seems to work in practice.
  • Loading branch information...
commit 943691dc8a529c50734d662380c4a1650883a3f7 1 parent 31535aa
@edsrzf edsrzf authored
Showing with 8 additions and 0 deletions.
  1. +8 −0 ironmq.go
View
8 ironmq.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
+ "io"
"io/ioutil"
"math/rand"
"net/http"
@@ -73,9 +74,13 @@ func (c *Client) req(method, endpoint string, body []byte, data interface{}) err
const maxRetries = 5
tries := uint(0)
+ expectingEOF := false
var resp *http.Response
for tries < maxRetries {
resp, err = http.DefaultClient.Do(req)
+ if expectingEOF && err == io.EOF {
+ continue
+ }
if err != nil {
return err
}
@@ -88,6 +93,9 @@ func (c *Client) req(method, endpoint string, body []byte, data interface{}) err
delayMs := time.Duration(localRand.Int63n(pow))
time.Sleep(delayMs * time.Millisecond)
req.Body = ioutil.NopCloser(bytes.NewBuffer(body))
+ // the next retry is expected to fail; issue between Go's
+ // core library and ELB
+ expectingEOF = true
continue
}
break
Please sign in to comment.
Something went wrong with that request. Please try again.