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?

5
  • 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 Commented Jan 22, 2018 at 22:07
  • 2
    I think the timeout came from the server, not the browser. You should check the server configuration Commented Jan 22, 2018 at 22:15
  • what is the error in the console and network tab? Commented Jan 23, 2018 at 6: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. Commented Mar 14, 2018 at 10:51
  • @Zlatko thanks for that - it was the issue I was having. Commented Nov 13, 2018 at 16:18

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.