Hi all,

Thanks a lot Rob for your sample code.

I'm still looking for the cause of the problem, but here are some details about the configuration of the Apache HTTPClient. Some properties of this client connector can be configured (see http://www.restlet.org/documentation/1.0/connectors#httpclient), and among them "maxConnectionsPerHost" and "connectionManagerTimeout". You can set them this way :

Client client = new Client(component.getContext(), Protocol.HTTPS);
client.getContext().getParameters().add("maxConnectionsPerHost", "10");
client.getContext().getParameters().add("connectionManagerTimeout", "1000");
component.getClients().add(client);

By default "maxConnectionsPerHost" allows only 2 connections for one host (I still agree there is a problem, because these connections cannot be reused...). "connectionManagerTimeout" sets the time to wait for closing a blocking connection, by default its value is 0 which means infinity...

best regards,
Thierry Boileau

I attached a test case that's repeatable for me. Takes 3 requests (of any flavor) to cause the lockup. No idea why.

----- Original Message -----
From: "Thierry Boileau" <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, September 5, 2007 5:33:02 PM (GMT-0500) America/New_York
Subject: Re: issue with org.restlet.Client

Hello Nicolas,

I've created the issue 357
(http://restlet.tigris.org/issues/show_bug.cgi?id=357).
I've tried with a very simple HTTPS server (using jetty server
connector) and was not able to reproduce your pb.
Could you tell us more about your context : server, client connectors, etc.
Did you try to only get the cvs file? Did you try to create a new client
instance just for getting the csv file?

best regards,
Thierry Boileau

> Hi,
>
> first of all, kudos for your great work. We are using your framework
> intensively in our production environment and it works like a charm.
>
> I have stumbled with an issue with org.restlet.Client, that you might be able > to solve. We need to navigate through a website and retrieve a csv file in a
>  3-step process:
>  + POST some credentials, inspect the response for a redirect,
>  + GET to the redirect and
>  + GET to a csv resource.
>
> This is the code that hangs in the last GET for the csv file:
>
> Form form = new Form();
> form.add("organizationId", "xxxxx");
> form.add("username", "CCCC");
> form.add("password", "VVVVV");
>
> Client ebcClient = new Client(Protocol.HTTPS);
> Response loginResponse =
> ebcClient.post("https://xxxxxxx.com/ebctest/login/LoginProcess.do";,
> form.getWebRepresentation());
> Reference reference = loginResponse.getRedirectRef();
> ebcClient.get(reference);
> String yearMonthDay = "2007/08/28";
> Response reportResponse =
> ebcClient.get("https://xxxxxx/DownloadReport/"+yearMonthDay+
> "/overstock_test/PaymentBatchDetailReport.csv");
>
>
> However the following equivalent code works perfectly fine:
>
>
> HttpClient httpClient = new HttpClient();
> PostMethod httpLoginPost = new
> PostMethod("https://xxxxx/ebctest/login/LoginProcess.do";);
> NameValuePair[] postData = {
>  new NameValuePair("organizationId", "xxxxxx"),
>  new NameValuePair("username", "xxxxxx"),
>  new NameValuePair("password", "xxxxxx")
> };
>
> httpLoginPost.setRequestBody(postData);
> httpClient.executeMethod(httpLoginPost);
>
> String redirectLocation = httpLoginPost.getResponseHeader("location").getValue();
> GetMethod getLogin = new GetMethod(redirectLocation);
> httpClient.executeMethod(getLogin);
>
> String yearMonthDay = "2007/08/28";
> GetMethod csvGet = new
> GetMethod("https://xxxxxx/ebctest/DownloadReport/"+yearMonthDay+
> "/overstock_test/PaymentBatchDetailReport.csv");
>
> httpClient.executeMethod(csvGet);
>
> BufferedReader in = new BufferedReader(new
> InputStreamReader(csvGet.getResponseBodyAsStream()));
>
>     String line;
>     while((line = in.readLine()) != null) {
>       logger.debug(line);
>     }
> httpLoginPost.releaseConnection();
> getLogin.releaseConnection();
>
>
> This is the log where the org.restlet.Client hangs :
>
> 2007-08-31 09:25:49,303 [main] DEBUG
> org.apache.commons.httpclient.HttpMethodBase  -
> enter
> HttpMethodBase.processResponseHeaders(HttpState, HttpConnection)
> 2007-08-31 09:25:49,303 [main] DEBUG
> org.apache.commons.httpclient.HttpMethodBase  -
> enter
> HttpMethodBase.processCookieHeaders(Header[], HttpState, HttpConnection)
> 2007-08-31 09:25:49,303 [main] DEBUG
> org.apache.commons.httpclient.HttpMethodBase  -
> enter
> HttpMethodBase.readResponseBody(HttpState, HttpConnection)
> 2007-08-31 09:25:49,304 [main] DEBUG
> org.apache.commons.httpclient.HttpMethodBase  -
> enter HttpMethodBase.readResponseBody(HttpConnection)
> 2007-08-31 09:25:49,304 [main] DEBUG
> org.apache.commons.httpclient.HttpConnection  -
> enter HttpConnection.getResponseInputStream()
> 2007-08-31 09:25:49,304 [main] DEBUG
> org.apache.commons.httpclient.HttpMethodBase  -
> enter HttpMethodBase.canResponseHaveBody(int)
> 2007-08-31 09:25:49,304 [main] DEBUG
> org.apache.commons.httpclient.HttpMethodDirector  -
> Redirect required
> 2007-08-31 09:25:55,324 [main] DEBUG
> org.apache.commons.httpclient.methods.GetMethod  -
> enter GetMethod(String)
> 2007-08-31 09:25:55,325 [main] DEBUG org.apache.commons.httpclient.HttpClient -
>
> enter HttpClient.executeMethod(HttpMethod)
> 2007-08-31 09:25:55,325 [main] DEBUG org.apache.commons.httpclient.HttpClient -
>
> enter HttpClient.executeMethod(HostConfiguration,HttpMethod,HttpState)
> 2007-08-31 09:25:55,326 [main] DEBUG
> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager  -
>
> enter HttpConnectionManager.getConnectionWithTimeout(HostConfiguration, long)
> 2007-08-31 09:25:55,326 [main] DEBUG
> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager  -
>
> HttpConnectionManager.getConnection:  config =
> HostConfiguration[host=https://ebctest.cybersource.com], timeout = 0
> 2007-08-31 09:25:55,326 [main] DEBUG
> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager  -
> enter HttpConnectionManager.ConnectionPool.getHostPool(HostConfiguration)
> 2007-08-31 09:25:55,326 [main] DEBUG
> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager  -
> Unable to get a connection, waiting...,
> hostConfig=HostConfiguration[host=https://ebctest.cybersource.com]
>
>
>
> Thanks
>
> /Nic
>
>

Reply via email to