ITPub博客

首页 > > > http post请求管道断开

http post请求管道断开

作者:cjk 时间:2019-09-10 16:11:34 0 删除 编辑

通过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]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4715/viewspace-3168447/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-29

  • 博文量
    181
  • 访问量
    1134