Use default transport to close connections, set timeout at client #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using current master under go version go1.3.1 linux/amd64, we found that many connections to sendgrid were being orphaned in a
CLOSE_WAIT
state, leading to file descriptors that are never released. We traced the issue to the use of a custom Transport to implement dial timeouts not setting deadlines on other TCP operations (read, write, etc). This PR uses the Client.Timeout field to let the stdlib handle the timing out of connections, while using the DefaultTransport so that other transport defaults are set.The issue presents itself as thousands of
CLOSE_WAIT
connections to sendgrid when checkinglsof -l
With this patch, the connections are properly closed after the request is finished and no such entries can be found.
The Client.Timeout field was added in Go 1.3, so I think the travis build will fail for Go 1.1. Please advise if a Go 1.1 solution is necessary as well.