Help with lots of HttpClient errors
Lately I've been seeing tons of HttpClient exceptions in my AppCenter diagnostic reports, examples are:
System.Net.WebException
ModernHttpClient.NativeMessageHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0x105255f90 + 0x01143> in <67401bece23c4316a0cb1acd7b396157#792a49c16f2dfe546fe4e57621a98e65>:0
System.Net.WebException: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out."
System.Threading.Tasks.TaskCanceledException
NativeMessageHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
System.Threading.Tasks.TaskCanceledException: A task was canceled.
Now, while I understand that some users are in remote locations, maybe is there something wrong with ModernHttpClient?
Should I stop using it?
In my app, I defined it like this in App.xaml.cs:
private static HttpClient _myHttpClient;
public static HttpClient MyHttpClient
{
get
{
if (_myHttpClient == null)
{
_myHttpClient = new HttpClient(new NativeMessageHandler(false, new TLSConfig()))
{
Timeout = TimeSpan.FromSeconds(45),
BaseAddress = new Uri(Misc.Constants.ApiUrlsBase.BaseUrl),
};
_myHttpClient.DefaultRequestHeaders.Add(CustomRequestHeaders.ApiVersion, "2");
}
return _myHttpClient;
}
}
Can someone suggest a reason why I see so MANY errors like these? Anything obvious that I am missing?
Could this setting be an issue?