java.net.SocketException:软件导致连接中止:连接

时间:2010-01-13 19:22:17

标签: java networking https sockets

我正在尝试以编程方式(Java)打开指向网络上的调制解调器的URL。我已连接到网络,可以ping设备以及在浏览器中获取URL。但是,以编程方式,我在尝试打开连接时得到以下堆栈跟踪。

java.net.SocketException: Software caused connection abort: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:550)
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:141)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:272)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:329)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:172)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:793)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:158)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1041)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)

此外,URL使用https协议。

这是我的代码:

try {
        URL jipmURL = new URL("https://xxx.xxx.xxx.xxx/login.cgi");
        URLConnection urlConnection = jipmURL.openConnection();
        InputStreamReader streamReader = new InputStreamReader(
                                    jipmURLConnection.getInputStream());
        BufferedReader in = new BufferedReader(streamReader);

        StringBuffer stringBuffer = new StringBuffer();
        String inputLine;
        while ((inputLine = in.readLine()) != null) {
            stringBuffer.append(inputLine);
        }
        System.out.println("Results: " + stringBuffer);
        in.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

任何帮助将不胜感激,

史蒂夫

1 个答案:

答案 0 :(得分:1)

异常消息表明您甚至无法与Web服务器建立TCP连接。很难猜出确切的问题是什么,因为你能够从浏览器打开页面,但可能只是你正在运行软件防火墙,拒绝Java进程连接到该地址?