0

I have a springboot application with one Rest API. In that REST API, I am invoking another REST API (3rd party). I am connecting to it via RestTemplate something like below,

public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
    return restTemplateBuilder
            .setConnectTimeout(Duration.ofMillis(5000))
            .setReadTimeout(Duration.ofMillis(3000))
            .build();
}

Technically it working fine but sometimes, I am getting "java.net.SocketException: Connection reset " like 1 in 100 calls. Not able to understand why it is happening. Can anybody help to find the root cause and permanent fix for the same?

0 Answers0