Home > DeveloperSection > Forums > Connection Timeout in URLConnection using java?
Kate Smith
Kate Smith

Total Post:24

Posted on    October-05-2013 7:57 AM

 Java Java 

 1 Reply(s)
 1300  View(s)
Rate this:

In the below line of code to get the data from webservice. But its behavior is unexpected. Its return the data 7 to 8 times when I hit through code, but after that connection timeout error. Any Solution??

URL url = new URL(webPage);  
URLConnection urlConnection = url.openConnection();  
System.out.println("Connection Timeout  =====  "+urlConnection.getConnectTimeout());  
urlConnection.setRequestProperty("Authorization", "Basic " + authStringEnc);  
InputStream is = urlConnection.getInputStream();  
InputStreamReader isr = new InputStreamReader(is); 

It is return the Exception : java.net.SocketTimeoutException: connect timed out

Hank Greenberg
Hank Greenberg

Total Post:12

Posted on    October-05-2013 9:02 AM

This is may be internet connection issue (i.e. disconnected or slow). Increase your timeout duration.

Don't want to miss updates? Please click the below button!

Follow MindStick