HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
httpRequestFactory.setConnectionRequestTimeout(...);
httpRequestFactory.setConnectTimeout(...);
httpRequestFactory.setReadTimeout(...);
RestTemplate restTemplate = new RestTemplate(httpRequestFactory);
Site reliability engineering - SRE
Changing timeouts
Spring
RestTemplate
Use the HttpComponentsClientHttpRequestFactory
to add non-default configuration values to a RestTemplate
by doing the following:
Find more information about HttpComponentsClientHttpRequestFactory
at https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.html.