Skip to content

Conversation

lewislabs
Copy link

If httpRequest.GetResponse() internally throws a WebException then there is still a response stream to close. I believe this is causing sockets to remain open and leading to #152

@gokarnm
Copy link
Contributor

gokarnm commented Sep 30, 2016

Hi @lewislabs , thanks for the PR! I'll go through the change, test it and get back you.

@lewislabs
Copy link
Author

Thanks @gokarnm. I think these commits could also go into master. Let me know what you think.

@gokarnm
Copy link
Contributor

gokarnm commented Oct 4, 2016

Hi @lewislabs , the changes look good! I'm curious about how you tested this, specifically WriteContentToRequestBody() throwing an exception leading to CompleteFailedRequest() being called.

@lewislabs
Copy link
Author

Hi @gokarnm. I haven't tested this explicitly, I'm primarily going on this comment here https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/Amazon.Runtime/Pipeline/HttpHandler/HttpHandler.cs#L98

If the httpRequest.GetResponse() call throws an exception (more than likely a WebException) then the response variable will be null and will not be disposed. If you don't dispose of the response stream then this will leave a socket open in CLOSE_WAIT state and will keep hold of one of the connections from the ServicePoint's pool. If this happens a few times then you run the risk of using up all the sockets available to the ServicePoint and any subsequent httpWebRequest.GetResponse() calls will simply block forever.

@gokarnm gokarnm merged commit 4e475a6 into aws:aws-sdk-net-v2 Oct 6, 2016
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