Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase HTTP request timeout more than 2 minutes in Angular 7?

I have a request that takes more than 2 minutes to prepare the data in the backend and transmit it. The angular default time out for the HTTP request observable is 2 minutes. Any idea of how to increase the default timeout?

I read and tried the proposed solution in the following links, but all of them are working if you want to set the timeout less than 2 minutes, and none of them will work for increasing the timeout!!

https://rxjs-dev.firebaseapp.com/api/operators/timeout

Can't have a timeout of over 2 minutes with this.http.get?

How to increase waiting time for HttpClient request in angular 5?

How to set http call timeout in angularjs 4?

Default and specific request timeout

like image 771
Ahmad Tamimi Avatar asked Aug 08 '19 03:08

Ahmad Tamimi


People also ask

What is the default timeout for angular HTTP?

In complement to the other answers, just beware that if you use the proxy config on the dev machine, the proxy's default timeout is 120 seconds (2 minutes).

What is the max timeout for HTTP request?

The default time out value is 30 seconds. Thus, by default, the server will close the connection if idle for more than 30 seconds. The maximum value for this parameter is 300 seconds (5 minutes).


1 Answers

I didn't get a reply from you in the comments, but I was having this exact issue on my dev machine, and maybe that's happening to you as well.

I was using the proxy config, and the proxy's default timeout is 120 seconds (2 minutes). So, if that's your case, simply define a higher value in the configuration.

{
  "/api": {
    "target": "http://localhost:3000",
    "secure": false,
    "timeout": 360000
  }
}
like image 106
Marcos Dimitrio Avatar answered Oct 04 '22 01:10

Marcos Dimitrio