Reputation: 1421
We have an application where we do some internal http calls to a REST API to fetch the data. But some requests are taking longer than expected so I am trying to increase the timeout duration. I tried below things :
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(30 * 1000).build(); HttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).build();
But this doesn't solve my issue. This solution works only for the first time. But when I re run this request I get the timeout exception. Can anyone help me with this.
Below is the stack trace
HttpResponseProxy{HTTP/1.1 504 GATEWAY_TIMEOUT [Content-Length: 0, Connection: keep-alive] [Content-Length: 0,Chunked: false]}
Upvotes: 0
Views: 4947
Reputation: 79
You should also set socketTimeout (with setSocketTimeout() method).
Upvotes: 0