org.apache.commons.httpclient.HttpClient stuck on request

Posted by Roman on Stack Overflow See other posts from Stack Overflow or by Roman
Published on 2010-06-13T11:36:55Z Indexed on 2010/06/13 11:42 UTC
Read the original article Hit count: 660

Filed under:
|
|

Hi All

I have that code :

 while(!lastPage && currentPage < maxPageSize){


            StringBuilder request = new StringBuilder("http://catalog.bizrate.com/services/catalog/v1/us/" + " some more ...");

            currentPage++;
            HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager());
            client.getHttpConnectionManager().getParams().setConnectionTimeout(15000);



            GetMethod get = new GetMethod(request.toString());

            HostConfiguration configuration = new HostConfiguration();

            int iGetResultCode = client.executeMethod(configuration, get);
            if (iGetResultCode != HttpStatus.SC_OK) {
                System.err.println("Method failed: " + get.getStatusLine());
                return;
            }
            XMLStreamReader reader
                    = XMLInputFactory.newInstance().createXMLStreamReader(get.getResponseBodyAsStream());
            while (reader.hasNext()) {
                int type = reader.next();
            // some more xml parsing ... 
            }
            reader.close();
            get.releaseConnection();
          }

Somehow the code gets suck from time to time on line : executing request.

I cant find the configuration for a request time out (not the connection timeout) , can someone help me maybe , or is there something that I am doing basely wrong ?

The client I am using.

© Stack Overflow or respective owner

Related posts about java

Related posts about apache