本文介紹了java.io.IOException:在WebLogic服務器上使用AsyncRestTemplate時對等方重置連接的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我的Springboot應用程序部署在我的VP上的WebLogic服務器上,當我運行打算調用另一個網站的API方法的方法時,返回此錯誤:
java.util.concurrent.ExecutionException: java.io.IOException: Connection reset by peer
at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_144]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_144]
at org.springframework.util.concurrent.FutureAdapter.get(FutureAdapter.java:81) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_144]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_144]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_144]
Caused by: java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.readv0(Native Method) ~[na:1.8.0_144]
at sun.nio.ch.SocketDispatcher.readv(SocketDispatcher.java:43) ~[na:1.8.0_144]
at sun.nio.ch.IOUtil.read(IOUtil.java:278) ~[na:1.8.0_144]
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:440) ~[na:1.8.0_144]
at weblogic.socket.NIOInputStream.readInternal(NIOInputStream.java:168) ~[com.oracle.weblogic.server.muxers.jar:12.2.1.3]
at weblogic.socket.NIOInputStream.read(NIOInputStream.java:110) ~[com.oracle.weblogic.server.muxers.jar:12.2.1.3]
at weblogic.socket.NIOInputStream.read(NIOInputStream.java:73) ~[com.oracle.weblogic.server.muxers.jar:12.2.1.3]
at weblogic.socket.JSSEFilterImpl.readFromNetwork(JSSEFilterImpl.java:508) ~[com.oracle.weblogic.server.muxers.jar:12.2.1.3]
at weblogic.socket.JSSEFilterImpl.read(JSSEFilterImpl.java:470) ~[com.oracle.weblogic.server.muxers.jar:12.2.1.3]
at weblogic.socket.JSSESocket$JSSEInputStream.read(JSSESocket.java:119) ~[com.oracle.weblogic.server.muxers.jar:12.2.1.3]
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) ~[na:1.8.0_144]
at java.io.BufferedInputStream.read1(BufferedInputStream.java:286) ~[na:1.8.0_144]
at java.io.BufferedInputStream.read(BufferedInputStream.java:345) ~[na:1.8.0_144]
at weblogic.net.http.MessageHeader.isHTTP(MessageHeader.java:310) ~[com.oracle.weblogic.net.jar:12.2.1.3]
at weblogic.net.http.MessageHeader.parseHeader(MessageHeader.java:232) ~[com.oracle.weblogic.net.jar:12.2.1.3]
at weblogic.net.http.HttpClient.parseHTTP(HttpClient.java:554) ~[com.oracle.weblogic.net.jar:12.2.1.3]
at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:688) ~[com.oracle.weblogic.net.jar:12.2.1.3]
at weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLConnection.java:42) ~[com.oracle.weblogic.net.jar:12.2.1.3]
at weblogic.net.http.HttpURLConnection.getResponseCode(HttpURLConnection.java:1547) ~[com.oracle.weblogic.net.jar:12.2.1.3]
at org.springframework.http.client.SimpleBufferingAsyncClientHttpRequest$1.call(SimpleBufferingAsyncClientHttpRequest.java:94) ~[spring-web-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.http.client.SimpleBufferingAsyncClientHttpRequest$1.call(SimpleBufferingAsyncClientHttpRequest.java:77) ~[spring-web-4.3.11.RELEASE.jar:4.3.11.RELEASE]
... 4 common frames omitted
我注意到只有在使用Springs AsyncRestTemplate調用API調用時才會出現這種情況。
ListenableFuture<ResponseEntity<String>> y = asyncRestTemplate.exchange(desiredUrl, HttpMethod.GET, new HttpEntity<>("result"), String.class);//.get().getBody();
boolean done = false;
while (done == false)
{
if (y.isDone() == true)
{
response = y.get().getBody();
return response;
}
}
} catch (InterruptedException | ExecutionException ex) {
Logger.getLogger(HTTP_Methods.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
}
推薦答案
錯誤
Connection reset by peer
是遠程服務器(或它們之間的防火墻)發出的響應,聲明它將不會繼續完成此請求。
很可能是防火墻拒絕、SSL握手失敗、代理問題,甚至是HTTP失敗的請求。
這篇關于java.io.IOException:在WebLogic服務器上使用AsyncRestTemplate時對等方重置連接的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,