0

My Angular frontend selects parameters and then makes a HTTP GET api call to a Spring Boot application which executes a query.

Now, my query is quite complex and it easily takes atleast 3mins to complete it's execution and then return the result back to Angular.

After 2 mins of the api call from Angular, I can see below error appearing on the Chrome console. And even though Spring boot completes the execution, no response is received in Angular

zone.js:2935 GET http://localhost:4200/api/oonReimbursement?market=Jumbo&start=2018-1-1&end=2018-1-3 net::ERR_EMPTY_RESPONSE

Below is my get api call method

public getOonReport(searchCriteriaDTO: SearchCriteriaDTO): Observable < OonReimbursementDTO[] > {

  const cpParams = new URLSearchParams();
  cpParams.set('market', searchCriteriaDTO.marketSegment);
  cpParams.set('start', searchCriteriaDTO.effectiveStartDate.toString());
  cpParams.set('end', searchCriteriaDTO.effectiveEndDate.toString());
  const options = new RequestOptions({
    params: cpParams
  });

  console.log("REST API call = /api/oonReimbursement");

  return this.http.get('/api/oonReimbursement', options)
    .pipe(
      map((response: Response) => < OonReimbursementDTO[] > response.json()));

}

Below is my subscribe method in the angular component.

this.report1Service.getOonReport(searchCriteriaDTO).subscribe((data: OonReimbursementDTO[]) => this.oonReports = data);

If the query execution completes in less than 2 mins, we get perfect response.

Can someone help me on this if it is due to a timeout issue at angular end or something related to Rx Observables in http.get() api call ?

1 Answers1

0

You can use retry operator from rxjs to redo the request to your endpoint. Also, this question maybe can help u more.

Gois
  • 88
  • 1
  • 8