HttpClient timeouts before the timeout specified

后端 未结 2 1378
时光取名叫无心
时光取名叫无心 2021-01-15 08:15

I\'m using HttpClient from WP8 and do a Post request. I know the call may take long time as I\'m actually simulating slow network scenarios. Therefore I set the HttpCl

2条回答
  •  一向
    一向 (楼主)
    2021-01-15 09:15

    It is possible that you are hitting the timeout of the network stream. You can change this by doing,

    var handler = new WebRequestHandler();
    handler.ReadWriteTimeout= 5 * 60 * 1000;
    var client = new HttpClient(handler);
    client.Timeout = TimeSpan.FromMinutes(5);
    return await client.PostAsync(serverUri, httpContent).ConfigureAwait(false);
    

    The default on the desktop OS is already 5mins. However, it is possible that on Windows Phone it has been reduced by default.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题