Running into some error, I must be overlooking something.
How can I debug this? Dropping connections?
I read the following:
golang - Why net.DialTimeout get timeout half of the time?
Go. Get error i/o timeout in server program
golang get massive read tcp ip:port i/o timeout in ubuntu 14.04 LTS
Locating the "read tcp" error in the Go source code
Getting sporadic "http: proxy error: read tcp: i/o timeout" on Heroku
Error created here:
https://github.com/golang/go/blob/b115207baf6c2decc3820ada4574ef4e5ad940ec/src/net/net.go#L179
Goal:
Send a Get request to a url.
Expected result:
return body in JSON.
Encountered problem:
I/O timeout
It works in Postman
Edit:
I added a modified timeout...
Edit2: traced error
Postman request:
GET /v2/XRP-EUR/candles?interval=1h HTTP/1.1
Host: api.bitvavo.com
Postman Result (1440 rows):
[
[
1609632000000,
"0.17795",
"0.17795",
"0.17541",
"0.17592",
"199399.874013"
],
[
1609628400000,
"0.17937",
"0.18006",
"0.17622",
"0.17852",
"599402.631894"
],
[
1609624800000,
"0.18167",
"0.18167",
"0.17724",
"0.17984",
"579217.962574"
],.....
Code:
package main
import (
"fmt"
"net/http"
"io/ioutil"
"time"
)
func main() {
url := "https://api.bitvavo.com/v2/XRP-EUR/candles?interval=1h"
method := "GET"
client := &http.Client {
}
client.Timeout = time.Second * 60
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
result:
Get "https://api.bitvavo.com/v2/XRP-EUR/candles?interval=1h": dial tcp 65.9.73.10:443: i/o timeout
question from:
https://stackoverflow.com/questions/65545585/dial-tcp-i-o-timeout-with-http-get-request 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…