views:

720

answers:

2

I am trying to programmatically (Java) open a URL that points to a modem on the network. I am connected to the network and can ping the device as well as fetch the URL within a browser. However, programmatically, I get the following stack trace when trying to open the connection.

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)

Also, the URL uses the https protocol.

Here is my code:

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();
    }

Any help would be appreciated,

Steve

+1  A: 

The exception message indicates that you're not even able to establish a TCP connection with the web server. It's difficult to guess what the exact problem is, since you're able to open the page from a browser, but could it simply be that you're running a software firewall, which refuses the Java process to connect to that address?

jarnbjo
There is no software firewall running on my side. I dont know if the modem has some sort of "firewall" that blocks things, but one thing I notice is that it has a certificate error when I try to access the url in the browser. Could this be the issue?
stjowa
Can you check if you're able to open a plain TCP socket to the modem from your Java program using `new Socket("xxx.xxx.xxx.xxx", 443);`?
jarnbjo
Ok, just checked if I am able to open a plan TCP socket to the modem and I am not. It comes up with the same exception, error and stack trace. Any more ideas? Also, when I do a tracert, it gives me transmit error: code 1314.
stjowa
It did end up being a firewall. Thank you.
stjowa
A: 

i would like to know please what causes that when i am trying to entre chat website i am always receving the following message ( java.net SocketException: Socket read faild) please anwer me .

omar