hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Julius Davies" <juliusdav...@gmail.com>
Subject Re: Where is the SSL handShake is counted - ConnectionT/o or Socket T/o ?
Date Wed, 10 Jan 2007 19:42:33 GMT
Hi, Ranobroto,

It's a good question  I'm not really sure, myself.  You may want to try
experimenting by creating the basic Socket and SSLSocket objects in a little
test class, and reading a few bytes from the InputStreams.  See what kind of
soTimeout and connectTimeout values work when just dealing with raw Socket
and SSLSocket objects.

Don't forget to use the empty create method on the SocketFactory!

Socket s = socketFactory.createSocket();
s.setSoTimeout( 5 * 60 * 1000 );
InetSocketAddress target = new InetSocketAddress( "domain.com", 443 );
s.connect( target, 15 * 60 * 1000 );

I suspect that the SSL handshake is counted against soTimeout and not
connectTimeout, since SSL is layered on top of a plain socket.

yours,

Julius


On 1/10/07, Ranobroto Dutta <ranobroto@gmail.com> wrote:
>
> Hi All,
>
> I have been struggling with the Socket and Connection Timeouts with Apache
> httpclient. I am getting two types of exceptions in my code (follows),
> when
>
> 1. SocketTimeoutException
> 2. Null value !
>
> My question is Where is the SSL handShake is counted?
>
> Is it the connection timeout or the socket timeout ? I have been juggling
> with numbers as the Client takes anywhere from 7 - 120 seconds to process
> the request ! I am trying to get to the correct number for Connection and
> Socket Timeout.
>
> Can someone assist?
>
> // httpComm is a HttpClinet
>    httpComm.setConnectionTimeout( getHttpConnTimeout() );
>    httpComm.setTimeout( getHttpRespTimeout() );
>
>
>     // Execute request
>     try {
>         logIt( LoggerBase.INFO, "Executing Http post request..." );
>         result = _clnt.executeMethod( post );
>          logIt( LoggerBase.INFO, "HTTP response received..." );
>          logIt( LoggerBase.INFO, twoSpaces+"response status: "+
>                                 HttpStatus.getStatusText(result) );
>         // response header
>         Header[] rspHdr = post.getResponseHeaders();
>         logIt( LoggerBase.DATA, twoSpaces+"response header:" );
>         String hdroutput = new String();
>         for ( int i=0;i<rspHdr.length;i++ ) {
>             hdroutput += twoSpaces + rspHdr[i].toString();
>         }
>         logIt(LoggerBase.DATA, twoSpaces+hdroutput);
>         // response body
>         respBody = post.getResponseBodyAsString();
>         logIt(LoggerBase.DATA, twoSpaces+"response body:" );
>         logIt(LoggerBase.DATA, twoSpaces+respBody );
>     }
>     catch ( Exception e ) {
>         logIt(LoggerBase.WARN,"HttpClient/post failed (msg="+
>                 e.getMessage()+")");
> //        logIt(LoggerBase.WARN,"HttpClient/post status: "+
> //                                post.getStatusText());
>         e.printStackTrace( System.err );
>     }
>
> 2:16:36:40 09Jan07 |CngVal| Executing Http post request...
> 2-16:37:03 09Jan07 WARN |CngVal| HttpClient/post failed (msg=null)
>
>
> 6-14:08:01 05Jan07 |CngVal| Executing Http post request...
> 6:14:08:08 05Jan07 WARN |CngVal| HttpClient/post failed (msg=
> java.net.SocketTimeoutException: Read timed out)
>
>


-- 
yours,

Julius Davies
416-652-0183
http://juliusdavies.ca/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message