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
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).
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).
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
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With