set proxy host/port ???

  • Thread starter G. Garrett Campbell
  • Start date
G

G. Garrett Campbell

I am attempting to connect to a local proxy to inspect my internet trafic.

The proxy is listening to port 8888 so I though the attached code would
pass through it and I would the see request/response. Nothing happens in
the
proxy.

Java seems to be ignoring the proxySet stuff. I would have been happy just
to
get an error code something like invalid port

I attempted setting these parameters with the java -D
java -DproxySet=true -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888

Thanks for any suggestions

code example

import java.io.*;
import java.net.*;

class ProxyTest {

public static void main(String [] args) {
System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "http.proxySet", "true" ); //probably not
needed
System.getProperties().put( "http.proxyHost", "ggcdell" ); // name of my
computer
System.getProperties().put( "http.proxyPort", "8888" );
String ht = "http://csmerge.cira.colostate.edu";
try {
URL url = new URL(ht);
URLConnection conn = url.openConnection();
conn.connect();
DataInputStream s = new DataInputStream(conn.getInputStream());
String line = s.readLine();
while (line != null) {
System.out.println(line);
line = s.readLine();
}
s.close();
} catch (Exception ee) {
System.out.println(" should arrive here ");
ee.printStackTrace(System.out);
}
}
}
 
D

Danno

I am attempting to connect to a local proxy to inspect my internet trafic.

The proxy is listening to port 8888 so I though the attached code would
pass through it and I would the see request/response. Nothing happens in
the
proxy.

Java seems to be ignoring the proxySet stuff. I would have been happy just
to
get an error code something like invalid port

I attempted setting these parameters with the java -D
java -DproxySet=true -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888

Thanks for any suggestions

code example

import java.io.*;
import java.net.*;

class ProxyTest {

public static void main(String [] args) {
System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "http.proxySet", "true" ); //probably not
needed
System.getProperties().put( "http.proxyHost", "ggcdell" ); // name of my
computer
System.getProperties().put( "http.proxyPort", "8888" );
String ht = "http://csmerge.cira.colostate.edu";
try {
URL url = new URL(ht);
URLConnection conn = url.openConnection();
conn.connect();
DataInputStream s = new DataInputStream(conn.getInputStream());
String line = s.readLine();
while (line != null) {
System.out.println(line);
line = s.readLine();
}
s.close();
} catch (Exception ee) {
System.out.println(" should arrive here ");
ee.printStackTrace(System.out);
}
}

}

What response are you getting?
 
G

G. Garrett Campbell

I do not get any error message, just the contents of the web site.
That appears wether I have the proxy turned on or off.

Danno said:
I am attempting to connect to a local proxy to inspect my internet
trafic.

The proxy is listening to port 8888 so I though the attached code would
pass through it and I would the see request/response. Nothing happens in
the
proxy.

Java seems to be ignoring the proxySet stuff. I would have been happy
just
to
get an error code something like invalid port

I attempted setting these parameters with the java -D
java -DproxySet=true -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888

Thanks for any suggestions

code example

import java.io.*;
import java.net.*;

class ProxyTest {

public static void main(String [] args) {
System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "http.proxySet", "true" ); //probably not
needed
System.getProperties().put( "http.proxyHost", "ggcdell" ); // name of
my
computer
System.getProperties().put( "http.proxyPort", "8888" );
String ht = "http://csmerge.cira.colostate.edu";
try {
URL url = new URL(ht);
URLConnection conn = url.openConnection();
conn.connect();
DataInputStream s = new DataInputStream(conn.getInputStream());
String line = s.readLine();
while (line != null) {
System.out.println(line);
line = s.readLine();
}
s.close();
} catch (Exception ee) {
System.out.println(" should arrive here ");
ee.printStackTrace(System.out);
}
}

}

What response are you getting?
 
A

Andy Flowers

G. Garrett Campbell said:
I do not get any error message, just the contents of the web site.
That appears wether I have the proxy turned on or off.

Danno said:
I am attempting to connect to a local proxy to inspect my internet
trafic.

The proxy is listening to port 8888 so I though the attached code would
pass through it and I would the see request/response. Nothing happens in
the
proxy.

Java seems to be ignoring the proxySet stuff. I would have been happy
just
to
get an error code something like invalid port

I attempted setting these parameters with the java -D
java -DproxySet=true -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888

Thanks for any suggestions

code example

import java.io.*;
import java.net.*;

class ProxyTest {

public static void main(String [] args) {
System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "http.proxySet", "true" ); //probably not
needed
System.getProperties().put( "http.proxyHost", "ggcdell" ); // name of
my
computer
System.getProperties().put( "http.proxyPort", "8888" );
String ht = "http://csmerge.cira.colostate.edu";
try {
URL url = new URL(ht);
URLConnection conn = url.openConnection();
conn.connect();
DataInputStream s = new DataInputStream(conn.getInputStream());
String line = s.readLine();
while (line != null) {
System.out.println(line);
line = s.readLine();
}
s.close();
} catch (Exception ee) {
System.out.println(" should arrive here ");
ee.printStackTrace(System.out);
}
}

}
What response are you getting?

Try

System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "proxyHost", "ggcdell" );
System.getProperties().put( "proxyPort", "8888" );

Note no http. at the begining of the settings.
 
E

Esmond Pitt

G. Garrett Campbell said:
Java seems to be ignoring the proxySet stuff.

It does. See below.

I would have been happy just
System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "http.proxySet", "true" );

Neither of these has any effect whether set to 'true' or 'false'. Urban
legend (and several books) notwithstanding, there are no such properties
in Java and never have been. They were defined for the shortlived
HotJavaBean which lived and died around 1998.
 
E

Esmond Pitt

Andy said:
System.getProperties().put( "proxyHost", "ggcdell" );
System.getProperties().put( "proxyPort", "8888" );

Note no http. at the begining of the settings.

Don't expect any change from doing this. These are just synonyms for the
http.* names, which are preferred and should be used.
 
E

Esmond Pitt

G. Garrett Campbell said:
I do not get any error message, just the contents of the web site.
That appears wether I have the proxy turned on or off.

See my other posting. You can't turn it off, except by deleting
http.proxyHost/proxyPort. If it works when you set these properties,
your proxy is working. Isn't that what you expect?
 
G

G. Garrett Campbell

I got the following to work

System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "http.proxyHost", "127.0.0.1" ); // name of
my computer
System.getProperties().put( "http.proxyPort", "8888" );
 
E

Esmond Pitt

G. Garrett Campbell said:
I got the following to work

System.getProperties().put( "proxySet", "true" );

OK so try that with 'false' and tell us what difference it makes. My
prediction: zero.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top