I have an httpclient like this :
var client = new HttpClient();
I post to it like this:
var result = client.PostAsync(
endpointUri,
requestContent);
And get the response like this:
HttpResponseMessage response = result.Result;
I understand this call will block the thread, thats how its supposed to work (just building a tool for myself, no async threads needed)
The first time I run this call, it takes about 2 minutes to get a result. Meanwhile, if I do the exact same call elsewhere its done in 200ms. Even if I hit google, it takes 2 minutes. But, after the first call, as long as I keep the app open any additional calls are good. Its just the first cal when I open the application. What could be causing this?
The problem was that it was hanging for a very long time trying to resolve a proxy for the client. Initializing the HttpClient like this did the trick:
var client = new HttpClient(new HttpClientHandler
{
UseProxy = false
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With