Ahmad Tamimi
Ahmad Tamimi

Reputation: 295

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

Upvotes: 16

Views: 37810

Answers (1)

Marcos Dimitrio
Marcos Dimitrio

Reputation: 6852

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. The timeout must be set in milliseconds (it's set to 6 minutes in the example below).

{
  "/api": {
    "target": "http://localhost:3000",
    "secure": false,
    "timeout": 360000
  }
}

Upvotes: 18

Related Questions