I need to change the timeout for a web service call. Despite the configuration changes in several places, I go into timeout after 30 seconds. Any ideas?
My configuration :
private static final Duration CUSTOM_TIMEOUT = Duration.ofMinutes(5);
...
RequestConfig config = RequestConfig.custom()
.setSocketTimeout(300000)
.setConnectTimeout(300000)
.setConnectionRequestTimeout(300000)
.build();
CloseableHttpClient client = HttpClientBuilder
.create()
.setDefaultRequestConfig(config)
.build();
RestTemplate restTemplate = new RestTemplateBuilder()
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.errorHandler(new RestTemplateResponseErrorHandler())
.setConnectTimeout(CUSTOM_TIMEOUT)
.setReadTimeout(CUSTOM_TIMEOUT)
.build();
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(client);
factory.setConnectTimeout(300000);
factory.setReadTimeout(300000);
factory.setConnectionRequestTimeout(300000);
restTemplate.setRequestFactory(factory);
Thanks
A gateway timeout (504) indicates that the server you are talking to has reached its own timeout waiting for another service.
The timeout of that server seems to be 30 seconds, and you simply cannot configure it from your code, no matter what library you use.