Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensuring all HTTP connections are properly closed #357

Merged
merged 1 commit into from
May 19, 2017

Conversation

nathankurtyka
Copy link

Hello, and great work on this library!

We've recently discovered an HTTP connection leak can occur under network edge conditions.

This is a pull request that ensures that "... that the entity content has been fully consumed and the underlying stream has been closed" (https://hc.apache.org/httpcomponents-client-4.5.x/tutorial/html/fundamentals.html)

Specifically, the code below reads the full response (while still preserving the code's dependency on accessing the response InputStream), as well as guaranteeing that the response is closed. Both of these steps are important, and are consistent with the HttpClient recommendations.

Let me know if you have any questions! We've been running these modifications in Production for several days now and have not seen the connection leak since.

@jingming
Copy link
Contributor

@nathankurtyka There appears to be a compilation error in your code https://travis-ci.org/twilio/twilio-java/builds/225457155

@nathankurtyka
Copy link
Author

@jingming - D'oh.. sorry about that. The branch has been fixed.

Let me know if you have any questions! In debugging the leak I had to get somewhat deep into HttpClient, and I'd be happy to save you that time.

@jingming
Copy link
Contributor

@nathankurtyka great, thanks for the PR! We will take a look at this further as soon as we can, so please bear with us!

@jingming jingming merged commit 62a4097 into twilio:master May 19, 2017
@nathankurtyka nathankurtyka deleted the connection-leak-fix branch May 23, 2017 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants