R
Robert Mazur
I'm looking for some general guidance regarding https connection versus
http using Java. Might be some good puzzles for some of you. I have
tried this requesting two servers in two entirely different domains,
from two different locations. Exact same results. I am using jsse 1.0.3.
#1-DELAY) I have some code that used to fetch data from a web server
via https in about 5-7 seconds. I haven't used the code for 8 months,
and now when coming back to it I find that a round-trip connection (ie.
getting some data back) with either of two servers takes 25-30 seconds.
The same code using just http is instant, as I would expect. Why is
my getting OutputStream taking forever (see below)?
#2-JDK) My code works while using jsdk1.3. But if I switch to
jsdk1.4.2 (still using jsse1.0.3), I get a "java.net.ConnectException:
Connection timed out: connect" when connecting to the servers via https.
It's the same configuaration, as I am just asking Eclipse to switch
JDK's. Something must be different in the java.net.* package. But what?
// I pulled out all the try-catches to make more readable for now
HttpURLConnection connection;
URL url;
// Create new URL and connect
java.security.Security.addProvider(
new com.sun.net.ssl.internal.ssl.Provider());
System.getProperties().put(
"java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
url = new URL("https://www.somevaliddomain.com");
connection = (HttpsURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
if (this.encodedPass != null)
connection.setRequestProperty(
"Proxy-Authorization", this.encodedPass);
// SEND REQUEST TO SERVER
String queryString = "valid_request_for https_server";
//NEXT LINE TAKES AVE OF 20 SECONDS with jdk1.3
//or fails using jsdk1.4.2
OutputStream out = connection.getOutputStream();
out.write(queryString.getBytes());
out.close();
// READ THE ANSWER
String data = readURLConnection(connection);
http using Java. Might be some good puzzles for some of you. I have
tried this requesting two servers in two entirely different domains,
from two different locations. Exact same results. I am using jsse 1.0.3.
#1-DELAY) I have some code that used to fetch data from a web server
via https in about 5-7 seconds. I haven't used the code for 8 months,
and now when coming back to it I find that a round-trip connection (ie.
getting some data back) with either of two servers takes 25-30 seconds.
The same code using just http is instant, as I would expect. Why is
my getting OutputStream taking forever (see below)?
#2-JDK) My code works while using jsdk1.3. But if I switch to
jsdk1.4.2 (still using jsse1.0.3), I get a "java.net.ConnectException:
Connection timed out: connect" when connecting to the servers via https.
It's the same configuaration, as I am just asking Eclipse to switch
JDK's. Something must be different in the java.net.* package. But what?
// I pulled out all the try-catches to make more readable for now
HttpURLConnection connection;
URL url;
// Create new URL and connect
java.security.Security.addProvider(
new com.sun.net.ssl.internal.ssl.Provider());
System.getProperties().put(
"java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
url = new URL("https://www.somevaliddomain.com");
connection = (HttpsURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
if (this.encodedPass != null)
connection.setRequestProperty(
"Proxy-Authorization", this.encodedPass);
// SEND REQUEST TO SERVER
String queryString = "valid_request_for https_server";
//NEXT LINE TAKES AVE OF 20 SECONDS with jdk1.3
//or fails using jsdk1.4.2
OutputStream out = connection.getOutputStream();
out.write(queryString.getBytes());
out.close();
// READ THE ANSWER
String data = readURLConnection(connection);