Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

HttpClient Send Async Too many files open

$
0
0

Hi guys,

Im build an api client, that used the .net HttpClient class

I have my request wrapped in a using, properly working at start, but after some time leaving the phone without touching it, the http client always gives me socket error.
When my app starts, and if i am using it normally, nothing happens, only after i leave it without using for about 5 to 10min

This is the inner exception:
System.Net.Sockets.SocketException: Too many open files
at System.Net.Sockets.Socket..ctor (AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType) [0x00000] in :0
at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x00000] in :0

And this my stack trace:
at System.Threading.Tasks.TaskFactory1[System.IO.Stream].InnerInvoke (System.Threading.Tasks.TaskCompletionSource1 tcs, System.Func`2 endMethod, IAsyncResult l) [0x00000] in :0

End of stack trace from previous location where exception was thrown

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[System.IO.Stream].GetResult () [0x00000] in :0
at System.Net.Http.HttpClientHandler+c__async0.MoveNext () [0x00000] in :0

End of stack trace from previous location where exception was thrown

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[System.Net.Http.HttpResponseMessage].GetResult () [0x00000] in :0
at System.Net.Http.HttpClient+c__async0.MoveNext () [0x00000] in :0

End of stack trace from previous location where exception was thrown

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0
at System.Runtime.CompilerServices.TaskAwaiter`1[System.Net.Http.HttpResponseMessage].GetResult () [0x00000] in :0
at Classifieds.Mobile.Data.Utilities.ApiHelper+d__2.MoveNext () [0x00000] in :0

The code does this has a request:
using (HttpClient httpClient = new HttpClient())
{
//Request is built separately
var response = await httpClient.SendAsync(request, cancellationToken);
//in here i handle the response for this api call
}

any ideas on what might be happening?


Viewing all articles
Browse latest Browse all 58056

Trending Articles