How do I keep a long running http post request alive with Angular and rxjs?

Viewed 260

I have an http post request that takes a very long time to respond. There isn't a way to speed up the api response due to things out of my control (It contacts a server and gathers data from a mainframe that takes forever). I make this request using Angular 7 and rxjs 6, something like below:

// Angular component
this.exampleService.downloadCSV().subscribe( response => {
    // do something with response object
}

// Angular service
downloadCSV(): Observable<any> {
    return this.http.post(url, requestBody, {responseType: 'text'});
}

The problem is that the connection for this endpoint disconnects after 120 seconds due to an apache timeout. If it matters, this api is a Spring Framework REST api that for this endpoint returns a ResponseEntity.

Is there any way to periodically let the server know "Hey I'm here, don't time out yet!" using Angular or rxjs without having to mess around with the apache settings? Or a way to refresh the connection every minute or so that it doesn't time out?

I thought maybe the rxjs retry operator would help but I don't want to send a new http post request. Any help or guidance is appreciated!

EDIT: I'm not sure it is possible so I am going to see if it is possible to allow for streaming of data from the mainframe to the api instead of waiting for the whole very large CSV file to be completely generated before sending.

0 Answers
Related