golang请求Orientdb http接口错误

I am playing wit golang and orientdb to test them. i have written a tiny web app which uppon a request fetches a single document from local orientdb instance and returns it. when i bench this app with apache bench, when concurrency is above 1 it get following error:

2015/04/08 19:24:07 http: panic serving [::1]:57346: Get http://localhost:2480/d ocument/t1/9:1441: EOF

when i bench Orientdb itself, it runs perfectley OK with any cuncurrency factor. also when i change the url to fetch from this document to anything (other program whritten in golang, some internet site etc) the app runs OK. here is the code:

func main() {
    fmt.Println("starting ....")

    var aa interface{}
    router := gin.New()
    router.GET("/", func(c *gin.Context) {
        ans := getdoc("http://localhost:2480/document/t1/9:1441")
        json.Unmarshal(ans, &aa)
        c.JSON(http.StatusOK, aa)
    })

    router.Run(":3000")
}
func getdoc(addr string) []byte {
    client := new(http.Client)
    req, err := http.NewRequest("GET", addr, nil)
    req.SetBasicAuth("admin","admin")
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("oops", resp, err)
        panic(err)
    }
    defer resp.Body.Close()
    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        panic(err)
    }
    return body
}

thanks in advance

The keepalive connections are getting closed on you for some reason. You might be overwhelming the server, or going past the max number of connections the database can handle.

Also, the current http.Transport connection pool doesn't work well with synthetic benchmarks that make connections as fast as possible, and can quickly exhaust available file descriptors or ports (issue/6785).

To test this, I would set Request.Close = true to prevent the Transport from using the keepalive pool. If that works, one way to handle this with keepalive, is to specifically check for an io.EOF and retry that request, possibly with some backoff delay.