You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Albretch Mueller <lb...@gmail.com> on 2008/02/11 19:48:08 UTC

trying to connect out through a proxy

 Right now I am using a browser that connects out though a proxy
server using the IP:Post settings:
~
 10.0.1.47:9090
~
 but ISA is gives em as errors:
~
C:\cmllpz\prjx\java\net\net02>java ProxyTunnelDemo02
Socket not created: HTTP/1.1 502 Proxy Error (The specified Secure
Sockets Layer (SSL) port is not allowed. ISA Server is not configured
to allow SSL requests from this port. Most Web browsers use port 443
for SSL requests.)
~
C:\cmllpz\prjx\java\net\net02>java -Dhttp.proxyHost=10.0.1.47
-Dhttp.proxyPort=9090 ProxyTunnelDemo02
Socket not created: HTTP/1.1 502 Proxy Error ( The specified Secure
Sockets Layer (SSL) port is not allowed. ISA Server is not configured
to allow SSL requests from this port. Most Web browsers use port 443
for SSL requests.  )
~
 here is my code
~
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.ProxyClient.*;
import java.net.Socket;
// __
public class ProxyTunnelDemo02{
 public static void main(String args[]){
  String aSite = "www.google.com";
  String aProxy = "10.0.1.47";
  int iPort = 9090;
  String aUserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3";

  ProxyClient client = new ProxyClient();
  client.getParams().setParameter("http.useragent", aUserAgent);
// __
  client.getHostConfiguration().setHost(aSite);
  client.getHostConfiguration().setProxy(aProxy, iPort);
// __
  Socket socket = null;
  try{
   ConnectResponse response = client.connect();
   socket = response.getSocket();
   if(socket == null){
    ConnectMethod method = response.getConnectMethod();
    System.err.println("Socket not created: " + method.getStatusLine());
   }
   // do something
  }
  catch(Exception X){ X.printStackTrace(); }
  finally{
   if(socket != null){
    try { socket.close(); }catch(Exception x){}
   }
  }
 }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org