Context
I have a spring boot application that fires a request to a third party's API called NMI (payment provided gateway). The request is fired using RestTemplate.exchange
//Constructing necessary parameters
HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(parameters, headers);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(nmiTransactionURL);
startTimeLog // added log to get time when request was sent
ResponseEntity<String> response = restTemplate.exchange(builder.build().encode().toUri(), HttpMethod.POST, entity, String.class);
endTimeLog // added log to get time when response was received
Just before firing the request and just after getting the response we make a log entry.
Problem
- According to our log entries the time difference between startTimeLog and endTimeLog (from the code above) is say 5+ minutes intermittently and <10 seconds other times.
- The above time difference started happening recently(15-20 days back). Before that we got response withing 1 minute.
- According to NMI they are giving the response within 1 minute and that the 5 minute request is reaching their application server with a delay of 4 minutes.
Infrastructure
Note that my springboot application is deployed in an EC2 instance in private subnet and another EC2 instance is used as NAT server through which this request to NMI is being sent (to NMI’s servers)
My Question are
- Has anyone else faced the same issue with NMI recently?
- What can be other possible causes (other than NMI sending late response) that can lead to this issue. I understand one possibility is that the requests are being queues in NAT server in our infrastructure. How can I find out if that is the case?