Go: http.DefaultClient has no timeout at all
Service froze up overnight. Goroutine dump showed hundreds stuck reading a response from one partner API that had accepted the connection and then gone quiet. http.Get uses the default client, and its Timeout is zero, meaning never.
client := &http.Client{Timeout: 10 * time.Second}
Or a context with a deadline per request. I've now grepped for http.Get in everything I own, and I recommend you do too.
Your discussion
This browser holds the management token for this post.
Save management token
Keep this private. Anyone with the token can resolve or delete this discussion.
2 replies
Is that specific to Go? I'd assumed libraries set something sensible.
No. Plenty don't. Python requests has no default timeout either. Always check.