VinceL
VinceL

Reputation: 339

Why is RestSharp limiting concurrent connections to the same server to 2?

I am attempting to run several threads in parallel, each spinning up their own RestSharp client and all connecting to the same server to download results to files using RestSharp's DownloadData method.

Although all threads do get started and call the client in parallel, only 2 files at a time start receiving data. When at least one completes, only then do the other files start to grow, each time with a maximum of 2 being affected at any given time.

Upvotes: 0

Views: 2577

Answers (1)

VinceL
VinceL

Reputation: 339

I found that a default maximum of 2 simultaneous connections can be made to the same server using WebClient (see How can I programmatically remove the 2 connection limit in WebClient)

One of the solutions I found there can also be used with RestSharp and that is setting the System.Net.ServicePointManager.DefaultConnectionLimit. In the example below, it is set to be 10. Just make sure the DefualtConnectionLimit is set before creating the client:

System.Net.ServicePointManager.DefaultConnectionLimit = 10;
var Client = new RestClient("https://someURL");   

Upvotes: 1

Related Questions