4

I am making a POST request to the backend. The stuff happening on the backend is pretty complicated, and will take a few minutes to return a response. Unfortunately, the POST request is timing out after exactly 1 minute. I need the browser to wait longer than 1 minute for a response.

Here is my original code:

bulkLookupRequest(req) {
    return this.http.post(this.bulkLookupUrl, req)
    .toPromise();
}

I have searched and searched for a solution online. I have tried:

bulkLookupRequest(req) {
    return this.http.post(this.bulkLookupUrl, req)
    .timeout(600000) // ten minutes
    .toPromise();
}

Which still timed out after exactly 1 minute.

I have also tried:

bulkLookupRequest(req) {
    return this.http.post(this.bulkLookupUrl, req, { headers: new HttpHeaders({ timeout: `${600000}` }) })
    .toPromise();
}

It still timed out after 1 minute.

Am I missing something? Could something else, like Apache settings, be interfering?

Josh
  • 614
  • 1
  • 10
  • 17
  • 1
    have you tried using `Observable` instead of `Promise` . however i strongly recommend sending the request to initiate the 'complicated code' asynchronously (without waiting the response) then let the server push notification back to client when it finishes using something like [signalR](https://www.google.com/search?q=signalR&oq=signalR&aqs=chrome..69i57j35i39l2j0l3.2256j0j7&sourceid=chrome&ie=UTF-8) – Modar Na Jan 22 '18 at 22:07
  • 2
    I think the timeout came from the server, not the browser. You should check the server configuration – Noémi Salaün Jan 22 '18 at 22:15
  • what is the error in the console and network tab? – Max Koretskyi Jan 23 '18 at 06:15
  • 3
    Frequently the servers (or rev-proxies in between) will force these timeouts. Try doing it on a dummy endpoint locally that does not cut off and never hangs up. – Zlatko Mar 14 '18 at 10:51
  • @Zlatko thanks for that - it was the issue I was having. – Wagner Danda da Silva Filho Nov 13 '18 at 16:18

0 Answers0