java.net.sockets and MS Proxy

J

Jack Vamvas

I am currently working on a whiteboard application , that uses
java.net.socket as the connection method.
If MS Proxy 2 is not involved between the 2 machines then the connection
works fine.
If, on the other hand, the requestor makes the request from behind MS Proxy
2 then the connection fails.

has anyone had a similar problem, if so, some tips on how I could get around
this problem would be good.

JV





___________________________________________________________________
Remotely manage MS SQL db with SQLdirector -
www.ciquery.com/tools/sqldirector/
 
T

Tim Jowers

Jack Vamvas said:
I am currently working on a whiteboard application , that uses
java.net.socket as the connection method.
If MS Proxy 2 is not involved between the 2 machines then the connection
works fine.
If, on the other hand, the requestor makes the request from behind MS Proxy
2 then the connection fails.

has anyone had a similar problem, if so, some tips on how I could get around
this problem would be good.

JV
You have to configure the proxy according to what type it is. Thank
Michael Montuori for this code...mybe you want to contract him for
some contract work :)


System.out.println(" -t {1|2|3|4} = 1-Sun
VM");
System.out.println("
2-Microsoft VM (Default)");
System.out.println(" 3-Cisco
PIX");
System.out.println(" 4-Socks
4 Proxy Servers");
System.out.println(" 5-Web
Ftp (default anonymous)");
....
if (proxyHost != null) {
if (proxyType.equals("1") || proxyType.equals("3")) {
System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "proxyHost", proxyHost);
System.getProperties().put( "proxyPort", proxyPort);
} else {
if (proxyType.equals("4")) {
System.getProperties().put( "socksProxySet",
"true");
System.getProperties().put( "socksProxyHost",
proxyHost);
System.getProperties().put( "SocksProxyPort" ,
proxyPort);
} else {
if (proxyType.equals("5")) {
System.getProperties().put( "ftpProxySet",
"true" );
System.getProperties().put( "ftpProxyHost",
proxyHost );
System.getProperties().put( "ftpProxyPort",
proxyPort );
} else {
System.getProperties().put("firewallSet",
"true");
System.getProperties().put("firewallHost",
proxyHost);
System.getProperties().put("firewallPort",
proxyPort);
System.getProperties().put("http.proxyHost",
proxyHost);
System.getProperties().put("http.proxyPort",
proxyPort);
}}}
if (https && proxyHost != null) {
System.getProperties().put("https.proxyHost",
proxyHost);
System.getProperties().put("https.proxyPort",
proxyPort);
}
}
....
if (proxyHost != null) {
Base64 base64 = new Base64(username + ":" + password);
base64.encode();
base64Encoded = "Basic " + base64.getOutgoing();
urlConnection.setRequestProperty("Proxy-Connection","Keep-Alive");
if (proxyType.equals("3")) {
urlConnection.setRequestProperty("Authorization",
base64Encoded);
} else {
urlConnection.setRequestProperty("Proxy-Authorization",
base64Encoded);
}

....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top