How to do an automatic reconnect after SocketTimeoutException?
<p>I set timeout for connections.</p>

<pre><code>HttpClient httpClient = org.apache.http.impl.client.HttpClientBuilder.create().build();

HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
factory.setConnectTimeout((int) TimeUnit.MINUTES.toMillis(2));
factory.setReadTimeout((int) TimeUnit.MINUTES.toMillis(2));
factory.setHttpClient(httpClient);

RestTemplate restTemplate = new RestTemplate(factory);
</code></pre>

<p>I want to send an request again 5 times after SocketTimeoutException. How can I do that automatically? </p>