gpt4 book ai didi

java - ClientAbortException : java.net.SocketException:jboss 服务器上间歇性出现连接重置错误

转载 作者:行者123 更新时间:2023-12-02 09:31:05 27 4
gpt4 key购买 nike

我的 Web 应用程序连接到 API 以从数据库获取数据。通过浏览器访问页面有时会正确加载数据,但有时会抛出连接重置异常。这种情况间歇性地发生。

大多数情况下首次加载不起作用,但刷新/重新加载页面可以暂时解决问题。

我的网页(UI)部署在Jboss服务器6.4上。我的前端 Web 应用程序和后端 API 之间有一个中间负载均衡器。

Web 应用程序的 Jboss 日志 -

ClientAbortException:  java.net.SocketException: Connection reset
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:429)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:450)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:368)
at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:342)
at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:99)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:141)
at java.io.FilterOutputStream.close(FilterOutputStream.java:158)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
at org.jboss.as.web.security.SubjectInfoSetupValve.invoke(SubjectInfoSetupValve.java:34)
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:656)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926)
at java.lang.Thread.run(Thread.java:748)
Suppressed: ClientAbortException: java.net.SocketException: Broken pipe (Write failed)
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:429)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:450)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:368)
at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:324)
at org.apache.catalina.connector.CoyoteOutputStream.close(CoyoteOutputStream.java:106)
at java.io.FilterOutputStream.close(FilterOutputStream.java:159)
... 25 more

调用 API 的代码段 -

private String invokeGetTLS(String apiHost, HttpServletResponse response) throws IOException {
System.out.println("Inside invokeGetTLS");
URL apiURL = null;
Map<String, List<String>> respHeaders = null;
HttpsURLConnection apiURLConnection = null;
try {
apiURL = new URL(apiHost);
apiURLConnection = (HttpsURLConnection) apiURL.openConnection();
apiURLConnection.setDoInput(true);
respHeaders = apiURLConnection.getHeaderFields();
addResponseHeaders(respHeaders, response);
} catch (IOException e) {
System.out.println("Exception in invokeGetTLS " + e.getMessage());
e.printStackTrace();
return e.getMessage();
}
try (BufferedInputStream inputBuffStream = new BufferedInputStream(apiURLConnection.getInputStream());
BufferedOutputStream outBuffStream = new BufferedOutputStream(response.getOutputStream())) {
int i;
while ((i = ((InputStream) inputBuffStream).read()) >= 0) {
outBuffStream.write(i);
}
} catch (IOException e) {
System.out.println("Exception in invokeGetTLS " + e.getMessage());
e.printStackTrace();
return e.getMessage();
}
System.out.println("Leaving invokeGetTLS");
return null;
}

我们正在使用 Nginx 网络服务器。流程是这样的 - Nginx->serve/UI ->Load Balancer -> Api 。我在 Nginx 上看到以下错误 -

2019/09/19 11:32:32 [info] 12553#12553: *6 epoll_wait() reported that client prematurely closed connection, so upstream connection is closed too while reading response header from upstream

最佳答案

ClientAbortException:  java.net.SocketException: Broken pipe

这意味着客户端关闭了连接。如果您有一个负载均衡器充当您所描述的客户端,则负载均衡器过早关闭了连接。调整负载均衡器超时。

关于java - ClientAbortException : java.net.SocketException:jboss 服务器上间歇性出现连接重置错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57971167/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com