LoveSeat icon indicating copy to clipboard operation
LoveSeat copied to clipboard

Fix for running out of connections

Open Ian1971 opened this issue 12 years ago • 3 comments

This was because when the response was being read the response was not closed at the end. This meant that after 12xnumber cpu cores requests we were out of connections and just got timeouts.

Ian1971 avatar Apr 26 '12 10:04 Ian1971

Good catch. The only place it is needed though is in the GetResponsestring. I'll make the change e when I get to work

soitgoes avatar Apr 26 '12 12:04 soitgoes

I see, GetResponseStream closes the connection when the Stream closes.

Ian1971 avatar Apr 26 '12 12:04 Ian1971

The other place I can think of is ViewResult. Perhaps this should implement IDisposable and close the HttpWebResponse there.

Update: Oops. I see you're modifying the Extension class and not the CouchDatabase/ViewResult. If so, I'd recommend an optional argument (e.g. public static Document GetCouchDocument(this HttpWebResponse response, bool closeResponse=true)) so the extension methods don't carry the business logic of closing the connection.

nsainaney avatar Aug 07 '12 19:08 nsainaney