1

I was trying to access an operation from a https site after disabling http port in the server. It throwing the below error. When http is enabled its working fine. Then i am able to request using https .. Please find the code for enabling sslConnection below

public static void enableSSL() throws NoSuchAlgorithmException, KeyManagementException {
     TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {

            @Override
            public void checkClientTrusted(X509Certificate[] chain,
                    String authType) throws CertificateException {
                // TODO Auto-generated method stub

            }

            @Override
            public void checkServerTrusted(X509Certificate[] chain,
                    String authType) throws CertificateException {
                // TODO Auto-generated method stub

            }

            @Override
            public X509Certificate[] getAcceptedIssuers() {
                // TODO Auto-generated method stub
                return null;
            }



        } };
        // Install the all-trusting trust manager
        SSLContext sc = SSLContext.getInstance("SSL");
        // Create empty HostnameVerifier
        HostnameVerifier hv = new HostnameVerifier() {


            @Override
            public boolean verify(String arg0, SSLSession arg1) {
                // TODO Auto-generated method stub
                return true;
            }
        };

        sc.init(null, trustAllCerts, new java.security.SecureRandom());
        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
        HttpsURLConnection.setDefaultHostnameVerifier(hv);

}

Please find the error below

com.sun.xml.ws.client.ClientTransportException: HTTP transport error:
java.net.SocketTimeoutException: connect timed out at 
com.sun.xml.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:132) at 
com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:153) at 
com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:94) at 
com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:116) at
com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:598) at 
com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:557) at
com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:542) at 
com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:439) at 
com.sun.xml.ws.client.Stub.process(Stub.java:222) at 
com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:135) at 
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:109) at 
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89) at 
com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118) at 
$Proxy32.getStageRoot(Unknown Source) at 
com.hash.aif.client.file.AIFFilePortClient.getStageRoot(AIFFilePortClient.java:57) at 
com.hash.aif.client.AifSSLClient.main(AifSSLClient.java:21) Caused by:
java.net.SocketTimeoutException: connect timed out at 
java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at 
java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at 
java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at 
java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at 
java.net.AbstractPlainSocketImpl.connect(Unknown Source) at 
java.net.PlainSocketImpl.connect(Unknown Source) at 
java.net.SocksSocketImpl.connect(Unknown Source) at 
java.net.Socket.connect(Unknown Source) at 
sun.security.ssl.SSLSocketImpl.connect(Unknown Source) at 
sun.net.NetworkClient.doConnect(Unknown Source) at 
sun.net.www.http.HttpClient.openServer(Unknown Source) at 
sun.net.www.http.HttpClient.openServer(Unknown Source) at 
sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source) at 
sun.net.www.protocol.https.HttpsClient.New(Unknown Source) at 
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source) at 
sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at 
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source) at 
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source) at 
sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source) at 
com.sun.xml.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:120) ... 15 more
beerbajay
  • 19,652
  • 6
  • 58
  • 75
hashique
  • 357
  • 4
  • 11

1 Answers1

1

HTTPS is on a different port (443) than standard HTTP (80). The connection is timing out, so it is likely that either the server is not serving HTTPS (it's only serving HTTP) or there is some firewall issue preventing you from accessing port 443 on the target machine.

Here is the relevant part of the error stack indicating the connection timeout:

Caused by:
java.net.SocketTimeoutException: connect timed out at 
java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at 
java.net.DualStackPlainSocketImpl.socketConnect(Unknown S
Francis Upton IV
  • 19,322
  • 3
  • 53
  • 57
  • I have tried enabling both http and https. The request url is https and more over if comment my ssl enabler code .. It use to throw ssl exception.. Which means its using ssl .. The problem comes only when i comment the http code – hashique Jun 12 '12 at 18:50