Guys,

Can any one help me out in resolving  "java.net.SocketException: Operation 
timed out: connect:could be due to invalid address"


/*
 * Created on Sep 5, 2007
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package com;

/**
 * @author naranapattyk
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
import java.io.BufferedReader;
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  import java.io.Writer;
  import java.net.Socket;

  import javax.net.ssl.SSLSocketFactory;

  public class Test {
 
         public static final String TARGET_HTTPS_SERVER = 
"www.verisign.com"; 
         public static final int    TARGET_HTTPS_PORT   = 443; 
 
         public static void main(String[] args) throws Exception {
 
           Socket socket = SSLSocketFactory.getDefault().
                 createSocket(TARGET_HTTPS_SERVER, TARGET_HTTPS_PORT);
           try {
                 Writer out = new OutputStreamWriter(
                        socket.getOutputStream(), "ISO-8859-1");
                 out.write("GET / HTTP/1.1\r\n"); 
                 out.write("Host: " + TARGET_HTTPS_SERVER + ":" + 
                         TARGET_HTTPS_PORT + "\r\n"); 
                 out.write("Agent: SSL-TEST\r\n"); 
                 out.write("\r\n"); 
                 out.flush(); 
                 BufferedReader in = new BufferedReader(
                        new InputStreamReader(socket.getInputStream(), 
"ISO-8859-1"));
                 String line = null;
                 while ((line = in.readLine()) != null) {
                        System.out.println(line);
                 }
           } finally {
                 socket.close(); 
           }
         }
  }


I tried running the above code in two different network

1) System with proxy setting - execution failed got 
"java.net.SocketException: Operation timed out: connect:could be due to 
invalid address"
2) System without proxy settings -  executed sucessfully

I got  this code from "http://commons.apache.org/httpclient/sslguide.html";
This code is to test the SSL and JSSE configuration.


can anyone help me out to make this code run successfully in the system 
having proxy settings enabled. 


Thank You

Viswa


Reply via email to