Hi Oleg,

I got the code of your EasySSLProtocolSocketFactory from the link of
http://hc.apache.org/httpclient-3.x/sslguide.html. And I used Java 5. Did these 
ensured the two things you mentionsed - "the latest version" and "Java 1.4 
detached socket API" ? 

Can you please help check whether my code has any problem? I ran it and both 
connection and read timeout did not work. There must be something wrong.

Thanks for your reply.
Ben

>>>>>>>Code I used to test<<<<<<<
String host ="rtdsl-uat.princetonecom.com";
String dest = "/pngRTDS/scanline/xml";

/*------------*/
EasySSLProtocolSocketFactory factory = new EasySSLProtocolSocketFactory();
Protocol sslProtocol = new Protocol("https", factory, 443);
HostConfiguration hostConf = new HostConfiguration();
hostConf.setHost(host, 443, sslProtocol);

// Will pick up sslProtocol from hostConf
PostMethod postmethod = new PostMethod(dest);
HttpClient client = new HttpClient();
/*--------------*/

hostConf.getParams().setParameter("http.socket.timeout", 200);

client.getHttpConnectionManager().getParams().setConnectionTimeout(100);
client.getHttpConnectionManager().getParams().setSoTimeout(100);

reportDuration(start);
try {
        int statusCode = client.executeMethod(hostConf, postmethod);
        reportDuration(start);
        System.out.println("statusCode = " + statusCode);
        if (statusCode != HttpStatus.SC_OK) {
                System.err.println("HTTPS Post failed [" + url + ", "
                                + postmethod.getStatusText() + "]");
                throw new IOException("HTTPS Post failed [" + url + ", "
                                + postmethod.getStatusText() + "]");
        }

        String responseBody = postmethod.getResponseBodyAsString();
        System.out.println("Recieved response from server...\n" + responseBody);
} catch(IOException ioe) {
        System.out.println("sslPostMsg2(): exception caught>>> " + 
ioe.getMessage());
        System.out.println("sslPostMsg2(): " + ioe.getCause());
        throw ioe;
} finally {
        postmethod.releaseConnection();
}



--- On Tue, 11/4/08, Oleg Kalnichevski <[EMAIL PROTECTED]> wrote:

> From: Oleg Kalnichevski <[EMAIL PROTECTED]>
> Subject: Re: httpclient timeout: https vs. http
> To: "HttpClient User Discussion" <[email protected]>
> Date: Tuesday, November 4, 2008, 3:45 AM
> On Fri, 2008-10-31 at 10:39 -0700, Ben Smith wrote:
> > Hi Oleg,
> > 
> > I used your EasySSLProtocolSocketFactory and tried the
> following code. Timeout still wouldn't work. Can you
> please help?
> > 
> 
> Ben
> 
> I just double-checked. EasySSLProtocolSocketFactory handles
> connect
> timeouts correctly. Make sure you have the latest version
> of the socket
> factory or make sure the code you have makes use of Java
> 1.4 detached
> socket API
> 
> Oleg
> 
> 
> > Thanks,
> > Ben
> > 
> > EasySSLProtocolSocketFactory factory = new
> EasySSLProtocolSocketFactory();
> >             HttpClient client = new HttpClient();
> >
>               
> client.getHttpConnectionManager().getParams().setConnectionTimeout(100);
> >             
> >             Protocol easyhttps = new Protocol("https",
> factory, 443);
> >
>               
> client.getHostConfiguration().setHost("rtdsl-uat.princetonecom.com",
> 443, easyhttps);
> >             GetMethod httpget = new
> GetMethod("/pngRTDS/scanline/xml");
> >             try {
> >                     client.executeMethod(httpget);
> >                     System.out.println(httpget.getStatusLine());
> >             } finally {
> >                     httpget.releaseConnection();
> >             }
> > 
> > 
> > 
> > 
> > 
> > --- On Fri, 10/31/08, Oleg Kalnichevski
> <[EMAIL PROTECTED]> wrote:
> > 
> > > From: Oleg Kalnichevski <[EMAIL PROTECTED]>
> > > Subject: Re: httpclient timeout: https vs. http
> > > To: [email protected]
> > > Date: Friday, October 31, 2008, 8:23 AM
> > > On Thu, 2008-10-30 at 15:54 -0700, Ben Smith
> wrote:
> > > > Hi All,
> > > > 
> > > > I ran a code from one of your post as below
> by Oleg
> > > with two different urls.
> > > > url 1: http://www.au.yahoo.com/
> > > > url 2:
> > >
> https://rtdsl-uat.princetonecom.com/pngRTDS/scanline/xml
> > > > 
> > > > url 1 gave the same result as your post,
> while url 2
> > > always succeeded and output the following even I
> set timeout
> > > to 100 milliseconds. How can I set timeout for
> this https
> > > url? Please help.
> > > > 
> > > > Thanks,
> > > > Ben
> > > 
> > > Ben,
> > > 
> > > This is a known limitation of HttpClient 3.x due
> to Java
> > > 1.2.2
> > > compatibility requirement. You can solve the
> problem by
> > > proving an
> > > implementation of SecureProtocolSocketFactory
> that can can
> > > handle
> > > connect timeouts using Java 1.4 API
> > > 
> > > Oleg
> > > 
> > > >
> ---------------------------------------------------
> > > > Code (by Oleg):
> > > > 
> > > > HttpClient client = new HttpClient();
> > > >
> > >
> client.getHttpConnectionManager().getParams().setConnectionTimeout(100);
> > > > GetMethod httpget = new GetMethod(url);
> > > > try {
> > > >   client.executeMethod(httpget);
> > > >  
> System.out.println(httpget.getStatusLine());
> > > >  
> > >
> System.out.println(httpget.getResponseBodyAsString());
> > > > } finally {
> > > >   httpget.releaseConnection();
> > > > }
> > > > 
> > > >
> ---------------------------------------------------
> > > > ......elapsed 0 seconds
> > > > ......elapsed 5 seconds
> > > > HTTP/1.1 200 OK
> > > > 
> > > > <?xml version="1.0" ?>
> > > > <RESPONSE version="1.0">
> > > >    ....
> > > > </RESPONSE>
> > > > 
> > > > 
> > > >       
> > > > 
> > > >
> > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> > > [EMAIL PROTECTED]
> > > > For additional commands, e-mail:
> > > [EMAIL PROTECTED]
> > > > 
> > > 
> > > 
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > [EMAIL PROTECTED]
> > > For additional commands, e-mail:
> > > [EMAIL PROTECTED]
> > 
> > 
> >       
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> > For additional commands, e-mail:
> [EMAIL PROTECTED]
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]


      

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to