I have this code:
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(40 * 1000)
.setConnectionRequestTimeout(40 * 1000)
.setSocketTimeout(40 * 1000)
.build();
client = HttpClientBuilder
.create()
.setDefaultRequestConfig(requestConfig)
.build();
}
and
try {
Stopwatch stopWatch = Stopwatch.createStarted();
response = client.execute(new HttpGet(routingRequestUrl));
stopWatch.stop();
} catch (Exception e) {
answer.errorMsg = e.getMessage();
answer.latency = null;
}
when my client configuration is as doesn't contain .setSocketTimeout(40 *
1000)
- the stopWatch shows request can take more then 1 minute.
It happens when I try setConnectTimeout
and setConnectionRequestTimeout
each alone or all together.
Why is only .setSocketTimeout(40 * 1000)
effectively checks timeout 40 seconds? and the other alone not?
These are the prints:
Read timed out
Timeout waiting for connection from pool
Is the first triggered by setConnectionRequestTimeout
and the second by setSocketTimeout
?