Is there any limit of HTTP requests in UWP apps? RRS feed

  • Question

  • I've encountered an issue, that in my UWP app I can make only limited number of HTTP requests.

    I'm doing HTTP requests consequentially and they start failing after 8191 attempts. And I got this number constantly. No difference if I make requests for existing URL or non existing URL

    This is the exception, that I get:

    "Message":"The text associated with this error code could not be found.\r\n\r\nNo more Internet handles can be allocated\r\n",
    "StackTraceString":"   at Windows.Web.Http.Filters.HttpBaseProtocolFilter.SendRequestAsync(HttpRequestMessage request)\r\n   at System.Net.Http.HttpHandlerToFilter.SendAsync(HttpRequestMessage request, CancellationToken cancel)\r\n   at System.Net.Http.HttpClientHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)",

    Is it a strict limitation of UWP or any windows apps? Can this limit be changed somewhere in the registry? Thank you in advance!

    Tuesday, October 29, 2019 9:21 AM

All replies

  • Hi,

    Did you release it after calling HttpClient?

    Please use the HttpClient.Dispose() method, or use the using statement:

    using (var client = new HttpClient())
        // Code here
    Best regards.

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 29, 2019 11:10 AM
  • PM for the Network Developer Experience team here -- you might get this problem if you don't fully drain the response each time?

    I've tried to repro your problem with reading the entire response each time and couldn't repro the problem. I did a loop (10,000 long) and read in a value from a URL; I didn't notice any different at the 8192 mark versus any other GET.

    Variations I tried:

    • Debug and Release
    • URL exists or doesn't exist (I tried "http://localhost/no_such_file.txt" and "http://www.msftconnecttest.com/connecttest.txt")
    • Using Windows.Web.Http.HttpClient (TryGetStringAsync()) and System.Net.Http.HttpClient (GetStringAsync)
    • Getting and ignoring a stream (.GetStreamAsync) for both Windows.Web and System.Net versions

    In all cases I just used the same HttpClient for all requests, and didn't try to make a parallel version. You should attempt to re-use the HttpClient if at all possible.

    Thursday, November 14, 2019 11:37 PM