hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "KOTA, KUMAR \(SBCSI\)" <kk9...@sbc.com>
Subject RE: Inconsistent socket time outs
Date Tue, 15 Mar 2005 22:43:54 GMT
Thanks Oleg,  If that is the case, then shouldn't either
client.executeMethod() wait until all the data is read or
buffer.readLine() should wait until all the data is read?  Why is it
that client.executeMethod() and buffer.readLine()  perform the timeouts?

Kumar Kota
SBC Information Technology
kk9142@sbc.com
(925) 901-6898


-----Original Message-----
From: Oleg Kalnichevski [mailto:olegk@apache.org] 
Sent: Tuesday, March 15, 2005 2:37 PM
To: HttpClient Project
Subject: Re: Inconsistent socket time outs


Kumar,

This is not a random behavior. The socket read timeout determines the
maximum period time the application can spend blocked waiting for
incoming data. As soon as some data is read from the socket the counter
is reset back to zero. The socket read timeout should not be mistakenly
equated with maximum execution time. The socket read timeout is the
maximum blocking time between two consecutive read operations.

Hope this helps

Oleg


On Tue, 2005-03-15 at 13:56 -0800, KOTA, KUMAR (SBCSI) wrote:
> Hi All,
> 
>     I am trying to timeout the socket using the httpclient
setSoTimeout
> but I am receiving inconsistent results.  The code I use is displayed
> below.  What is happenening is, sometimes the client.executeMethod is
> timing out and going straight to AREA 3 (indicated below).  But
> sometimes, the client.executeMethod is not timing out, it goes to AREA
2
> and then the bufferedReader.readLine() is timing out and it goes to
AREA
> 3.  This behavior happens randomly (about 35% of the time) and
> frequently enough to cause problems.  Any help on this would be great.
> 
> For example:  if timeout value is set to 7 seconds,
client.executeMethod
> runs for 4 seconds, passes to AREA 2 and then
bufferedReader.readLine()
> reads for 7 seconds and then times out (goes to AREA 3).  Whereas in
> other cases, client.executeMethod directly times out at 7 secnods and
> goes straight to AREA 3.
> 
> 
> 
> Here is the code:
> 
> try{
>      //MultiThreadedConnectionManager
>      MultiThreadedHttpConnectionManager manager = new
> MultiThreadedHttpConnectionManager();
>      HttpConnectionManagerParams params = manager.getParams();
>      params.setSoTimeout(timeoutVal);
>      manager.setParams(params);
> 
> 	// Create an instance of HttpClient.
>     	HttpClient client = new HttpClient(manager);
> 
> 	/************AREA 1******************************************/
> 		
>       // Execute the method.
>       int statusCode = client.executeMethod(method);
> 	
> 	InputStream response = method.getResponseBodyAsStream();
> 
> 	inpstrmrdr = new InputStreamReader(response);
> 	bufferedReader = new BufferedReader(inpstrmrdr);
> 	String outputline = "";	
> 
> 	/********* AREA 2 *******************************************/
> 	
> 	while ((outputline = bufferedReader.readLine()) != null) {
> 
> 		if (outputline.length() != 0) {
> 			sResponse = sResponse + outputline + "\n";
> 			//System.out.println("***********sResponse***" +
> sResponse);
> 		}
> 	}
> 
> } catch (java.io.InterruptedIOException e) {
>     
>      /********** AREA 3*********************************************/
> 
> }
> 
> Thank you,
> Kumar Kota
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
httpclient-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Mime
View raw message