AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to control the timeout of the whole session with HttpUrl

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language Programming
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Tue May 22, 2007 7:12 am    Post subject: How to control the timeout of the whole session with HttpUrl Reply with quote



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?
Back to top
SadRed
Guest





PostPosted: Tue May 22, 2007 7:12 am    Post subject: Re: How to control the timeout of the whole session with Htt Reply with quote



On May 22, 12:10 pm, billdavi...@gmail.com wrote:
Quote:
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?

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?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.