As Suggested by @John Wu's Answer on Stackoverflow. I am using the following code to make concurrent HTTP Get Requests on the same host for sending SMS
public async Task SendBulk(List<string> recipentURLs)
{
using (var client = new HttpClient())
{
//Start requests for all of them
var requests = recipentURLs.Select(url => client.GetAsync(url)).ToList();
//Wait for all the requests to finish
await Task.WhenAll(requests);
}
}
Now I am having the exception saying
System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
---> System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
The API I am sending requests to doesn't require a response (as I am only using it to send sms).
I am using this in a backgroud job by using HangFire. So I am okay if it takes a long time.
What I am currently looking is an efficient way to send multiple HTTP Get Requests at the Same host.
How can I safely handle all these concurrent requests and retry if any of it fails?
Also I am currently researching that due HTTP Throttling I cannot use 2 connection to the same host?