Tring to connect using HTTPS: Server redirected too many times
I am trying to connect to a secured connection URL (https://example.com ) using a Java program to check availability of the site. Generally, I connect to https://example.com in browser by disabling proxy settings. Also, we have installed certificates in trusted root certificates.
I have added these certificates to Java Keystore successfully.
import java.net.URL;
import java.net.URLConnection;
import java.security.Security.*;
import com.sun.net.ssl.*;
import com.sun.*;
import javax.net.ssl.HttpsURLConnection;
import java.security.cert.Certificate;
import java.io.*;
import javax.net.ssl.SSLPeerUnverifiedException;
import org.omg.CORBA_2_3.portable.InputStream;
public class TestConn
public static void main(String args )
try
URL hp = new URL("https://example.com");
HttpsURLConnection hpCon = (HttpsURLConnection)hp.openConnection();
boolean isProxy = hpCon.usingProxy();
System.out.println("is using proxy " + isProxy);
InputStream obj = (InputStream) hpCon.getInputStream();
while(obj.read()!=-1)
System.out.println(obj.read_char());
System.out.println("content >> " + obj.toString());
catch (Exception ex)
ex.printStackTrace();
I have encountered the following error:
java.net.ProtocolException: Server redirected too many times (20)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at TestConn.main(TestConn.java:28)
Can anyone please help me regarding this exception?
java https
add a comment |
I am trying to connect to a secured connection URL (https://example.com ) using a Java program to check availability of the site. Generally, I connect to https://example.com in browser by disabling proxy settings. Also, we have installed certificates in trusted root certificates.
I have added these certificates to Java Keystore successfully.
import java.net.URL;
import java.net.URLConnection;
import java.security.Security.*;
import com.sun.net.ssl.*;
import com.sun.*;
import javax.net.ssl.HttpsURLConnection;
import java.security.cert.Certificate;
import java.io.*;
import javax.net.ssl.SSLPeerUnverifiedException;
import org.omg.CORBA_2_3.portable.InputStream;
public class TestConn
public static void main(String args )
try
URL hp = new URL("https://example.com");
HttpsURLConnection hpCon = (HttpsURLConnection)hp.openConnection();
boolean isProxy = hpCon.usingProxy();
System.out.println("is using proxy " + isProxy);
InputStream obj = (InputStream) hpCon.getInputStream();
while(obj.read()!=-1)
System.out.println(obj.read_char());
System.out.println("content >> " + obj.toString());
catch (Exception ex)
ex.printStackTrace();
I have encountered the following error:
java.net.ProtocolException: Server redirected too many times (20)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at TestConn.main(TestConn.java:28)
Can anyone please help me regarding this exception?
java https
stackoverflow.com/questions/1828775/… (may be unrelated )
– Jayan
Jan 18 '13 at 4:08
So what is the value ofisProxy
? Does it claim you are using one or not?
– matt forsythe
Oct 30 '15 at 17:38
add a comment |
I am trying to connect to a secured connection URL (https://example.com ) using a Java program to check availability of the site. Generally, I connect to https://example.com in browser by disabling proxy settings. Also, we have installed certificates in trusted root certificates.
I have added these certificates to Java Keystore successfully.
import java.net.URL;
import java.net.URLConnection;
import java.security.Security.*;
import com.sun.net.ssl.*;
import com.sun.*;
import javax.net.ssl.HttpsURLConnection;
import java.security.cert.Certificate;
import java.io.*;
import javax.net.ssl.SSLPeerUnverifiedException;
import org.omg.CORBA_2_3.portable.InputStream;
public class TestConn
public static void main(String args )
try
URL hp = new URL("https://example.com");
HttpsURLConnection hpCon = (HttpsURLConnection)hp.openConnection();
boolean isProxy = hpCon.usingProxy();
System.out.println("is using proxy " + isProxy);
InputStream obj = (InputStream) hpCon.getInputStream();
while(obj.read()!=-1)
System.out.println(obj.read_char());
System.out.println("content >> " + obj.toString());
catch (Exception ex)
ex.printStackTrace();
I have encountered the following error:
java.net.ProtocolException: Server redirected too many times (20)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at TestConn.main(TestConn.java:28)
Can anyone please help me regarding this exception?
java https
I am trying to connect to a secured connection URL (https://example.com ) using a Java program to check availability of the site. Generally, I connect to https://example.com in browser by disabling proxy settings. Also, we have installed certificates in trusted root certificates.
I have added these certificates to Java Keystore successfully.
import java.net.URL;
import java.net.URLConnection;
import java.security.Security.*;
import com.sun.net.ssl.*;
import com.sun.*;
import javax.net.ssl.HttpsURLConnection;
import java.security.cert.Certificate;
import java.io.*;
import javax.net.ssl.SSLPeerUnverifiedException;
import org.omg.CORBA_2_3.portable.InputStream;
public class TestConn
public static void main(String args )
try
URL hp = new URL("https://example.com");
HttpsURLConnection hpCon = (HttpsURLConnection)hp.openConnection();
boolean isProxy = hpCon.usingProxy();
System.out.println("is using proxy " + isProxy);
InputStream obj = (InputStream) hpCon.getInputStream();
while(obj.read()!=-1)
System.out.println(obj.read_char());
System.out.println("content >> " + obj.toString());
catch (Exception ex)
ex.printStackTrace();
I have encountered the following error:
java.net.ProtocolException: Server redirected too many times (20)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at TestConn.main(TestConn.java:28)
Can anyone please help me regarding this exception?
java https
java https
edited Aug 21 '14 at 6:47
Raedwald
26.2k2296157
26.2k2296157
asked Jan 18 '13 at 3:54
vamsi krishnavamsi krishna
1111
1111
stackoverflow.com/questions/1828775/… (may be unrelated )
– Jayan
Jan 18 '13 at 4:08
So what is the value ofisProxy
? Does it claim you are using one or not?
– matt forsythe
Oct 30 '15 at 17:38
add a comment |
stackoverflow.com/questions/1828775/… (may be unrelated )
– Jayan
Jan 18 '13 at 4:08
So what is the value ofisProxy
? Does it claim you are using one or not?
– matt forsythe
Oct 30 '15 at 17:38
stackoverflow.com/questions/1828775/… (may be unrelated )
– Jayan
Jan 18 '13 at 4:08
stackoverflow.com/questions/1828775/… (may be unrelated )
– Jayan
Jan 18 '13 at 4:08
So what is the value of
isProxy
? Does it claim you are using one or not?– matt forsythe
Oct 30 '15 at 17:38
So what is the value of
isProxy
? Does it claim you are using one or not?– matt forsythe
Oct 30 '15 at 17:38
add a comment |
1 Answer
1
active
oldest
votes
If you want to check availability of the site, you should use hpCon.getResponseCode();
.
Response code 200
means that site is available. Frankly, i don't know your further purpose.
This is the modified codes, sure got the output content.
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
public class Test
public static void main(String args)
try
URL hp = new URL("https://godaddy.com");
HttpsURLConnection hpCon = (HttpsURLConnection) hp.openConnection();
boolean isProxy = hpCon.usingProxy();
System.out.println("is using proxy " + isProxy);
InputStream obj = hpCon.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(obj));
String s;
while ((s = br.readLine()) != null)
System.out.println("content >>" + s);
catch (Exception ex)
ex.printStackTrace();
Thank you for the response. My goal is to find the particular site is up and running fine or if the server is down without actually opening the site through a browser. We are connecting the site using HTTPS connection and checking the output content. But, the problem is we are able to access the site through browser but, not able to connect using Java. I am facing the above mentioned issue while doing the same.
– vamsi krishna
Jan 18 '13 at 6:06
so far your goal is output content. Let me do some modification of the code. 'java.io.InputStream obj = conn.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(obj)); String s; while((s= br.readLine())!= null) System.out.println(s); '
– THIHA SOE
Jan 18 '13 at 12:30
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14392120%2ftring-to-connect-using-https-server-redirected-too-many-times%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want to check availability of the site, you should use hpCon.getResponseCode();
.
Response code 200
means that site is available. Frankly, i don't know your further purpose.
This is the modified codes, sure got the output content.
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
public class Test
public static void main(String args)
try
URL hp = new URL("https://godaddy.com");
HttpsURLConnection hpCon = (HttpsURLConnection) hp.openConnection();
boolean isProxy = hpCon.usingProxy();
System.out.println("is using proxy " + isProxy);
InputStream obj = hpCon.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(obj));
String s;
while ((s = br.readLine()) != null)
System.out.println("content >>" + s);
catch (Exception ex)
ex.printStackTrace();
Thank you for the response. My goal is to find the particular site is up and running fine or if the server is down without actually opening the site through a browser. We are connecting the site using HTTPS connection and checking the output content. But, the problem is we are able to access the site through browser but, not able to connect using Java. I am facing the above mentioned issue while doing the same.
– vamsi krishna
Jan 18 '13 at 6:06
so far your goal is output content. Let me do some modification of the code. 'java.io.InputStream obj = conn.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(obj)); String s; while((s= br.readLine())!= null) System.out.println(s); '
– THIHA SOE
Jan 18 '13 at 12:30
add a comment |
If you want to check availability of the site, you should use hpCon.getResponseCode();
.
Response code 200
means that site is available. Frankly, i don't know your further purpose.
This is the modified codes, sure got the output content.
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
public class Test
public static void main(String args)
try
URL hp = new URL("https://godaddy.com");
HttpsURLConnection hpCon = (HttpsURLConnection) hp.openConnection();
boolean isProxy = hpCon.usingProxy();
System.out.println("is using proxy " + isProxy);
InputStream obj = hpCon.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(obj));
String s;
while ((s = br.readLine()) != null)
System.out.println("content >>" + s);
catch (Exception ex)
ex.printStackTrace();
Thank you for the response. My goal is to find the particular site is up and running fine or if the server is down without actually opening the site through a browser. We are connecting the site using HTTPS connection and checking the output content. But, the problem is we are able to access the site through browser but, not able to connect using Java. I am facing the above mentioned issue while doing the same.
– vamsi krishna
Jan 18 '13 at 6:06
so far your goal is output content. Let me do some modification of the code. 'java.io.InputStream obj = conn.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(obj)); String s; while((s= br.readLine())!= null) System.out.println(s); '
– THIHA SOE
Jan 18 '13 at 12:30
add a comment |
If you want to check availability of the site, you should use hpCon.getResponseCode();
.
Response code 200
means that site is available. Frankly, i don't know your further purpose.
This is the modified codes, sure got the output content.
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
public class Test
public static void main(String args)
try
URL hp = new URL("https://godaddy.com");
HttpsURLConnection hpCon = (HttpsURLConnection) hp.openConnection();
boolean isProxy = hpCon.usingProxy();
System.out.println("is using proxy " + isProxy);
InputStream obj = hpCon.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(obj));
String s;
while ((s = br.readLine()) != null)
System.out.println("content >>" + s);
catch (Exception ex)
ex.printStackTrace();
If you want to check availability of the site, you should use hpCon.getResponseCode();
.
Response code 200
means that site is available. Frankly, i don't know your further purpose.
This is the modified codes, sure got the output content.
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
public class Test
public static void main(String args)
try
URL hp = new URL("https://godaddy.com");
HttpsURLConnection hpCon = (HttpsURLConnection) hp.openConnection();
boolean isProxy = hpCon.usingProxy();
System.out.println("is using proxy " + isProxy);
InputStream obj = hpCon.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(obj));
String s;
while ((s = br.readLine()) != null)
System.out.println("content >>" + s);
catch (Exception ex)
ex.printStackTrace();
edited Jan 18 '13 at 12:52
answered Jan 18 '13 at 4:37
THIHA SOETHIHA SOE
11749
11749
Thank you for the response. My goal is to find the particular site is up and running fine or if the server is down without actually opening the site through a browser. We are connecting the site using HTTPS connection and checking the output content. But, the problem is we are able to access the site through browser but, not able to connect using Java. I am facing the above mentioned issue while doing the same.
– vamsi krishna
Jan 18 '13 at 6:06
so far your goal is output content. Let me do some modification of the code. 'java.io.InputStream obj = conn.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(obj)); String s; while((s= br.readLine())!= null) System.out.println(s); '
– THIHA SOE
Jan 18 '13 at 12:30
add a comment |
Thank you for the response. My goal is to find the particular site is up and running fine or if the server is down without actually opening the site through a browser. We are connecting the site using HTTPS connection and checking the output content. But, the problem is we are able to access the site through browser but, not able to connect using Java. I am facing the above mentioned issue while doing the same.
– vamsi krishna
Jan 18 '13 at 6:06
so far your goal is output content. Let me do some modification of the code. 'java.io.InputStream obj = conn.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(obj)); String s; while((s= br.readLine())!= null) System.out.println(s); '
– THIHA SOE
Jan 18 '13 at 12:30
Thank you for the response. My goal is to find the particular site is up and running fine or if the server is down without actually opening the site through a browser. We are connecting the site using HTTPS connection and checking the output content. But, the problem is we are able to access the site through browser but, not able to connect using Java. I am facing the above mentioned issue while doing the same.
– vamsi krishna
Jan 18 '13 at 6:06
Thank you for the response. My goal is to find the particular site is up and running fine or if the server is down without actually opening the site through a browser. We are connecting the site using HTTPS connection and checking the output content. But, the problem is we are able to access the site through browser but, not able to connect using Java. I am facing the above mentioned issue while doing the same.
– vamsi krishna
Jan 18 '13 at 6:06
so far your goal is output content. Let me do some modification of the code. 'java.io.InputStream obj = conn.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(obj)); String s; while((s= br.readLine())!= null) System.out.println(s); '
– THIHA SOE
Jan 18 '13 at 12:30
so far your goal is output content. Let me do some modification of the code. 'java.io.InputStream obj = conn.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(obj)); String s; while((s= br.readLine())!= null) System.out.println(s); '
– THIHA SOE
Jan 18 '13 at 12:30
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14392120%2ftring-to-connect-using-https-server-redirected-too-many-times%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
stackoverflow.com/questions/1828775/… (may be unrelated )
– Jayan
Jan 18 '13 at 4:08
So what is the value of
isProxy
? Does it claim you are using one or not?– matt forsythe
Oct 30 '15 at 17:38