首页 新闻 会员 周边 捐助

.net core 2.2 IHttpClientFactory 高并发请求 报错The operation was canceled.

0
悬赏园豆:5 [已解决问题] 解决于 2019-06-03 17:29

var httpclient = _httpClientFactory.CreateClient();
var url = "https://www.baidu.com/";
var rlt = await httpclient.PostAsync(url, new JsonContent(new { a = 1, b = 2 }));
var bts = await rlt.Content.ReadAsByteArrayAsync();

就是简单的post 百度网址 压测1000并发 单节点服务器
查看日志 有一部分出现
PostJson Error>>The operation was canceled. at System.Net.Http.HttpConnection.ContentLengthReadStream.CompleteCopyToAsync(Task copyTask, CancellationToken cancellationToken)
at System.Net.Http.HttpConnection.HttpConnectionResponseContent.SerializeToStreamAsync(Stream stream, TransportContext context, CancellationToken cancellationToken)
at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)

压测报告上平均响应时间快三秒 想问各位大佬是什么原因

tyree的主页 tyree | 初学一级 | 园豆:199
提问于:2019-05-14 12:05
< >
分享
最佳答案
1
收获园豆:5
dudu | 高人七级 |园豆:29568 | 2019-05-14 12:14
其他回答(2)
0

在压测的时候,看看你本地的TCP连接到达了多少。

Shendu.CC | 园豆:2138 (老鸟四级) | 2019-05-14 12:55
0

后续发现百度自身也不是每次都是有效response 换了同机房的接口测试 无异常

tyree | 园豆:199 (初学一级) | 2019-06-03 17:20
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册