I do not understand why it is currently impossible to disable persistent connections. I am currently using RestSharp in a production project and now I have to switch to a different framework. From the questions that have been asked on SO and here, this problem has been around for some time. In my opinion, this framework is garbage, and people wanting a truly configurable REST API framework should look elsewhere.
The exact problem is that RestSharp is reusing closed sockets. When this occurs, the RequestResponse.ErrorException is:
System.Net.WebException: The underlying connection was closed: An unexpected error
occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An
established connection was aborted by the software in your host machine. --->
System.Net.Sockets.SocketException: An established connection was aborted by the software in your host
machine
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean
probeRead)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at RestSharp.Http.GetRawResponse(HttpWebRequest request)
at RestSharp.Http.GetResponse(HttpWebRequest request)