3

I need to use multiple tasks that will hit a webservice end point. Each task will be streaming data and will have a httpWebRequest connection open.

I need to set the property ServicePointManager.DefaultConnectionLimit to a value greater than 2, but I'm using the portable framework and the ServicePointManager class is not available (should be in System.Net).

How do I allow more open webrequests in the portable framework?

Regards.

1 Answers1

0

I could not find a way to have more than 2 connections using webrequest objects in the portable framework, but I did find a way to have more concurrent connections. I'm just using the HttpClient class.

In my tests, when using HttpClient, you can use more than 2 concurrent connections. I have tried 10 and works fine.

The following test has 10 concurrent connections:

   var clients = new List<System.Net.Http.HttpClient>();

        for (int i = 0; i < 10; i++)
        {
            var client = new System.Net.Http.HttpClient();

            var response = client.GetAsync("http://www.google.com").Result;

            clients.Add(client);
        }
        foreach (var client in clients)
            client.Dispose();

This is a workaround. My original question, however, remains unanswered.