通过httpclient访问第三方接口,并发量上来总是出现管道断开异常,这个该如何处理比较好?
请求部分代码:
CloseableHttpClient client = HttpClients.createDefault();
String content = null;
CloseableHttpResponse resp = null;
try {
resp = client.execute(httpPost);
if (resp.getStatusLine().getStatusCode() == 200) {
HttpEntity he = resp.getEntity();
content = EntityUtils.toString(he, encode);
}
异常:
o.s.boot.context.web.ErrorPageFilter :Cannot forward to error page for request [/api/xx/xxx] as the response has already been committed.
Caused by: java.io.IOException: 断开的管道
at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.8.0_91]
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_91]
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_91]
at sun.nio.ch.IOUtil.write(IOUtil.java:65) ~[na:1.8.0_91]
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) ~[na:1.8.0_91]
at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:124) ~[tomcat-coyote.jar:8.0.28]
长风秋雁
相关分类