Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
373 views
in Technique[技术] by (71.8m points)

Make few requests every 5 minutes to external API from C# Web Service without exhausted all sockets

I need to send few requests to specific URL every 5 minutes from web service methods. I tried using HttpClient, HttpWebRequest and RestClient, but all sockets are exhausted after hour or two.

Can you suggest me what is the right way to send few requests to some URL every 5 minutes without all sockets to be exhausted? Thank you in advance for any help.

Sample of the code

private static HttpClient client = new HttpClient();
public async Task sendReq()
{
    client.DefaultRequestHeaders.ConnectionClose = true;
    var res = await client.GetStringAsync(url);
}
question from:https://stackoverflow.com/questions/65893208/make-few-requests-every-5-minutes-to-external-api-from-c-sharp-web-service-witho

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...