java.io.IOException:在WebLogic服务器上使用AsyncRestTemplate时对等方重置连接

java.io.IOException: Connection reset by peer#39; when using AsyncRestTemplate on weblogic server(java.io.IOException:在WebLogic服务器上使用AsyncRestTemplate时对等方重置连接)

本文介绍了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时对等方重置连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:java.io.IOException:在WebLogic服务器上使用AsyncRestTemplate时对等方重置连接

基础教程推荐