 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Tue May 22, 2007 7:12 am Post subject: How to control the timeout of the whole session with HttpUrl |
|
|
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
|
Posted: Tue May 22, 2007 7:12 am Post subject: Re: How to control the timeout of the whole session with Htt |
|
|
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 |
|
 |
|
|
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
|
|