Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2007

Tip: Looking for answers? Try searching our database.

How to control the timeout of the whole session with HttpUrlConnection?

Thread view: 
billdavidcn@gmail.com - 22 May 2007 04:10 GMT
How to control the timeout of the whole session with
HttpUrlConnection?

I find the following fact during test:
HttpUrlConnection.setConnectTimeout can only control the timeout of
connect operation, while setReadTimeout can only control the timeout
of read.
I have done an experiment and set timeout value in the following way:

m_connection.setConnectTimeout(1000);
m_connection.setReadTimeout(20 * 1000);

And in server side, I add the following sentence to make it delay to
response:
Thread.sleep(60 * 1000);

The result shows, client doesn't close the session in 20s, and the
communication completes after 60s when server responses it at last.

How could I close the session in 20s? I think to add a Timer should be
a solution, but is there any better choice?
SadRed - 22 May 2007 05:07 GMT
On May 22, 12:10 pm, billdavi...@gmail.com wrote:
> How to control the timeout of the whole session with
> HttpUrlConnection?
[quoted text clipped - 17 lines]
> How could I close the session in 20s? I think to add a Timer should be
> a solution, but is there any better choice?

> client doesn't close the session in 20s
Read would timeout and an exception would be thrown. What your client
were doing in that 20s?
billdavidcn@gmail.com - 22 May 2007 13:01 GMT
Thanks.
I have made a mistake, I have not handled the right exception, the
exception should be SocketTimeoutException.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.