Disabling keep-alive connections

3,213 views
Skip to first unread message

Aaron Seet

unread,
Jan 30, 2014, 2:03:18 AM1/30/14
to rest...@googlegroups.com
I am using RestSharp as the underlying HTTP library to stress test a black box service, I notice that after a while, even when testing has stop, the .NET process that runs the test/RestSharp keeps a lot of connections open. Since the Servicepoint limit has been lifted, it could be thousands of connections. If the test is sustained (continuous new requests), the response from the server will eventually grind to a halt for several seconds perhaps up to a minute, before exceptions with the connection happen.

Error 0 0
The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.
at RestSharp.Http.GetRawResponseAsync(IAsyncResult result, Action`1 callback)
at RestSharp.Http.ResponseCallback(IAsyncResult result, Action`1 callback)

Error 0 0
The underlying connection was closed: An unexpected error occurred on a receive.
at RestSharp.Http.GetRawResponseAsync(IAsyncResult result, Action`1 callback)
at RestSharp.Http.ResponseCallback(IAsyncResult result, Action`1 callback)

After a couple of hundreds of such errors, the client would be able to continue with its sustain rate of new requests and regular server response.

I am wondering how to disable HTTP keep-alive, in order to observe what kind of different behaviour may result from that?


thanks,
Aaron

Aaron Seet

unread,
Feb 2, 2014, 8:56:07 PM2/2/14
to rest...@googlegroups.com
Have some closer understanding what is driving the behaviour, as explained at


In summary, when the server is momentarily unable to sustain the rate at which the client is issuing requests, the client would reuse some extra HTTP connections it has kept open; which might have been closed by the server without the client's awareness.

Any way the preferred way to conduct this test is to open a new TCP connection for each HTTP request. But can't seem to find any option in RestSharp to control this.


thanks,
Aaron

David Redl

unread,
Mar 10, 2016, 1:49:14 PM3/10/16
to RestSharp
Did you ever find a solution to this? I am having the same problem and can't find a way to disable keep-alive in RestSharp
Reply all
Reply to author
Forward
0 new messages