In my Xpages application I am calling an external service to collect data.

Users are complaining that they sometimes get a timeout error message:

Connect to customerbank.acme.se:20543 [customerbank.acme.se/127.17.27.172] failed: Connection timed out: connect 

I assumed the timeout would result in an IOException but apparently not. How can I catch this error?

Below is part of my code. The logic of handling the response I have left out.

```
private CloseableHttpClient httpclient;

try{
    HttpClientBuilder cb = HttpClientBuilder.create();
    RequestConfig requestConfig = RequestConfig.custom()
                        .setSocketTimeout(30 * 1000)
                        .setConnectTimeout(30 * 1000)
                        .setConnectionRequestTimeout(30 * 1000)
                        .build();                   
    cb.setDefaultRequestConfig(requestConfig);
    httpclient = cb.build();
    HttpPost httpPost = new HttpPost(urlFromConfiguration);
    httpPost.setHeader("Content-Type", "application/json");
    HttpEntity entity;
    entity = new ByteArrayEntity(JSONobj.toString().getBytes("UTF-8"));
    httpPost.setEntity(entity);
    CloseableHttpResponse response = httpclient.execute(httpPost);
    if (200 == response.getStatusLine().getStatusCode()){//response received
        //perform some logic with the response... 
    }
} catch (IOException e) {
    OpenLogUtil.logError(e);
    FacesContext.getCurrentInstance().addMessage(null, new javax.faces.application.FacesMessage(javax.faces.application.FacesMessage.SEVERITY_ERROR, "some IO exception occurred", ""));
} catch (Exception e) {
    OpenLogUtil.logError(e);
    FacesContext.getCurrentInstance().addMessage(null, new javax.faces.application.FacesMessage(javax.faces.application.FacesMessage.SEVERITY_ERROR, "some general error has occured" , ""));
}

```