hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Heather Carter <heatherc...@gmail.com>
Subject Bizarre issue with CloseableHttpClient , every other httpget works
Date Fri, 25 Mar 2016 03:56:59 GMT
I have a program that goes out and gets a file from a https site, which for
now I have
simulated with a method on my service since the real site isn't ready.

The simulating method that returns a file with lines to process (it reads a
file from a local resource dir and streams it out):
https://mymachine:8443/myapp/contentsim/file1

The method that will make the HttpGet call to the simulator to get the file
and do the work
https://mymachine:8443/myapp/processfile/file1


I had to put in a timeout in my code so that I move past an issue where the
calls were hanging.
It now will successfully make the SSL handshake every other time.

 HttpGet get = null;
        RequestConfig params =
RequestConfig.custom().setConnectTimeout(5000).setSocketTimeout(5000).build();
        String docRetrievalUrl = "
https://mymachine:8443/myapp/contentsim/file1";
        get = new HttpGet(docRetrievalUrl);
        get.setConfig(params);

        LOGGER.info(">>> getDoc{}");
        //sslClientFactory sets up keystore and truststore and
trustmanagers & keymanagers
        //for 2 way ssl
        try (CloseableHttpClient httpClient =
this.sslClientFactory.getHttpClient();
             CloseableHttpResponse response = httpClient.execute(get)  ){

if (response !=null) {
                LOGGER.debug("Begin");
                HttpEntity entity = response.getEntity();
                if (entity !=null) {
                    InputStream is = entity.getContent();
                    InputStreamReader isr = new InputStreamReader(is);
                    BufferedReader br = new BufferedReader(isr);
                    LOGGER.error("Beggining to process content as csv");

                    try ( CSVReader csvReader = new CSVReader(br,',','"') )
{
                        String[] cells;
                        while ( (cells = csvReader.readNext()) != null ){

                            csvLines.add( new DataRow(cells) );
                        }

                    }
                    br.close();
                }
                LOGGER.debug("done");
            }


            } catch (IOException ex) {
               LOGGER("Problem " + ex.getMessage(),ex);
            }

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