?
Solved

URLConnection timeout

Posted on 2005-04-25
7
Medium Priority
?
530 Views
Last Modified: 2008-02-01
I have HttpsURLConnection connection.

When using 'inputStream = connection.getInputStream();' it waits too long.

How can I set an acceptable timeout time?

Rgds, Ales
0
Comment
Question by:drjustin
  • 4
  • 2
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 13858077
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 13858092
(5 seconds)

System.setProperty("sun.net.client.defaultConnectTimeout", "5000");
System.setProperty("sun.net.client.defaultReadTimeout", "5000");
0
 
LVL 3

Author Comment

by:drjustin
ID: 13858110
What happens then when timeout exceeds?
Is exception thrown?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 29

Expert Comment

by:bloodredsun
ID: 13858123
There is also the method:
public void setReadTimeout(int timeout)

where timout is milliseconds, but this is java 1.5
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13858125
Yes, so you need to handle it
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13858148
In the above method a SocketTimeoutException is raised, for the normal method I believe an IOException is raised.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13858232
:-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month17 days, 10 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question