TIL

Go’s http.Client waits forever by default

An http.Client without Timeout never gives up on a server that accepts the connection and then sends nothing. The probe hung on exactly that for 40 minutes during testing.

client := &http.Client{Timeout: 10 * time.Second}

Timeout covers the whole request, from dialling to the last byte of the body. For a check, that is the number we want.

Comments

Buy Logbuch