Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Timeout ignored in HttpClient

$
0
0

Hi, I have a strange behavior of timeout of HttpClient class. It is set to 55 seconds, but, in fact, it takes about 190 second :-O My code (It's a test)

var start = DateTime.Now;
try
{ using (var client = new HttpClient {Timeout = TimeSpan.FromMilliseconds(55000)})
{
var content = new StringContent(JsonConvert.SerializeObject(new {mock = "hello world"}),
System.Text.Encoding.UTF8, "application/json");
var response = client.PostAsync("https://172.18.0.2/mock_web", content).Result;
if (response.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result);
}
}
}
finally
{
Console.WriteLine("Duration: " + (DateTime.Now - start).TotalSeconds);
}

Aspected behavior:
app print Duration: 55
Actually behavior
App print Duration: 190,966736

I read about an old bug https://bugzilla.xamarin.com/show_bug.cgi?id=13200 but it has marked as "fixed" and the problem was about iOs, actually I tested this code on Android kit kat


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>