UWP http client delay in getting response

自作多情 提交于 2019-12-08 10:38:19

问题


I found this peculiar behaviour of UWP HttpClient.

For a simple get call of WCF service is taking time almost more than 100 seconds(happens for first few calls). I observed that the same service is way too faster in iOS and rest client.

Attaching the code, Please let me know, if i doing wrong.

            HttpClientHandler clientHandler = new HttpClientHandler();
            clientHandler.UseCookies = true;

            var client = new HttpClient(clientHandler);
            client.Timeout = TimeSpan.FromSeconds(100);

            client.DefaultRequestHeaders.Add("Accept", "application/json");

            var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, 
            requestUri);
            var response = await client.SendAsync(httpRequestMessage);

            //Between these lines there is a delay, it doesnt fire time out 
            also. I tried with HttpCompletionOption. No luck

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync(); 

            }

Any help will be really appreciated.

Thanks and Regards,

Rummy

来源:https://stackoverflow.com/questions/44741219/uwp-http-client-delay-in-getting-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!