UWP Windows.Web.Http.HttpClient Post send Header/Content multiple times in every 4 minutes

BB 1 Reputation point


I'm using Windows.Web.Http.HttpClient Post to make a webservice call, the server sometimes takes about 10 minutes to prepare the response for a time-consuming process. A response returns successfully after 10 minutes on our environment. I have the HttpProgress attached to the request, when the OnProgressChanged gets fired, it always has the same following sequence for every request,

Progress: Stage SendingHeaders

Progress: Stage SendingContent

Progress: Stage SendingContent

Progress: Stage WaitingForResponse


wait for 10 minutes


Progress: Stage ReceivingHeaders

Progress: Stage ReceivingContent 0.06 of 100 MB

Progress: Stage ReceivingContent 1.06 of 100 MB

Progress: Stage ReceivingContent 100 of 100 MB

and then the request will be successful, and I will get a HttpResponseMessage.

When we deploy the UWP app to the users' side, most of the time the requests are successful if the process time of server is less than 4 minutes. However, when the process time of the server is up to 7-10 minutes, the HttpClient will INTERNALLY send the same Header and Content multiple times to the server every 4 minutes, so that the call gets fail finally, please note that this is under the same request and we don't have any Retry implemented.

The interesting thing is that the stage DetectingProxy that doesn't happen in our environment.

5941|2020-06-10T18:51:27|Progress: Stage DetectingProxy

5942|2020-06-10T18:51:27|Progress: Stage SendingHeaders

5943|2020-06-10T18:51:27|Progress: Stage SendingContent

5944|2020-06-10T18:51:27|Progress: Stage SendingContent

5945|2020-06-10T18:51:27|Progress: Stage WaitingForResponse

5946|2020-06-10T18:56:04|Progress: Stage DetectingProxy

5947|2020-06-10T18:56:04|Progress: Stage SendingHeaders

5948|2020-06-10T18:56:04|Progress: Stage SendingContent

5949|2020-06-10T18:56:04|Progress: Stage SendingContent

5950|2020-06-10T18:56:04|Progress: Stage WaitingForResponse

5951|2020-06-10T19:00:04|Progress: Stage DetectingProxy

5952|2020-06-10T19:00:04|Progress: Stage SendingHeaders

5953|2020-06-10T19:00:04|Progress: Stage SendingContent

5954|2020-06-10T19:00:04|Progress: Stage SendingContent

5955|2020-06-10T19:00:04P|Progress: Stage WaitingForResponse

5956|2020-06-10T19:02:13|ERROR|2|At ServerProcess:

at SharedLibrary!<BaseAddress>+0x4d7bbd

at SharedLibrary!<BaseAddress>+0x4d7b08

at SharedLibrary!<BaseAddress>+0x4d7ac7

at APP!<BaseAddress>+0x179cea5

--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at SharedLibrary!<BaseAddress>+0x4d7b99

at SharedLibrary!<BaseAddress>+0x4d7b08

at SharedLibrary!<BaseAddress>+0x4d7ac7

at APP!<BaseAddress>+0x179c543

The request should not send Headers and Contents under the same request. Please HELP! Any ideas would be appreciated!

Thank you!

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. BB 1 Reputation point

    Hi @NicoZhu-MSFT ,

    Thank you so much for your reply. I haven't added the




    This is probably helpful.

    Is it required for a request that has a long responding time(more than 4 minutes)? The problem is that it internally resending data to the server multiple times on users' environment, however, it doesn't happen in our environment.

    Please see my code below,

         class RequestTest
             public async void Start()
                 Log.Trace("\n\nTest: Started");
                     string url = "http://server_url";
                     IProgress<HttpProgress> progress = new Progress<HttpProgress>(OnProgressChanged);
                     CancellationTokenSource cts = new CancellationTokenSource();
                     HttpClient httpClient = new HttpClient();
                     var httpRequestMsg = new HttpRequestMessage(HttpMethod.Post, new Uri(url));
                     long delay = 10 * 1000 * 60;
                     string data = $"name=myname&delay={delay}";
                     httpRequestMsg.Method = HttpMethod.Post;
                     httpRequestMsg.Content = new HttpStringContent(data);
                     httpRequestMsg.Content.Headers.ContentType = new HttpMediaTypeHeaderValue("application/x-www-form-urlencoded");
                     Log.Trace($"Delay time: {data}");
                     var response = await httpClient.SendRequestAsync(httpRequestMsg).AsTask(cts.Token, progress);
                     if (response.StatusCode == HttpStatusCode.Ok)
                         var res = await response.Content.ReadAsStringAsync();
                 catch (Exception ex)
                     Log.Error("\nException Message: \n", ex);
                 Log.Trace("\n\nTest: End");
             private void OnProgressChanged(HttpProgress progress)
                 //Log progress
    0 comments No comments