I have a request take about 2-5 minutes but it always break at 30s
Is there any way to increase request timeout or prevent request was canceled automatically with angular 8.x?
Asked
Active
Viewed 1,247 times
0

Ryan Nguyen
- 61
- 8
-
1You need to configure the timeout from the server-side. – Suren Srapyan Apr 27 '20 at 17:20
-
1Does this answer your question? [Default and specific request timeout](https://stackoverflow.com/questions/45938931/default-and-specific-request-timeout) – Avdhoota Apr 27 '20 at 17:26
-
Hi @SurenSrapyan, I see that my problem came from client side, my browser cancel request after 30s. – Ryan Nguyen Apr 28 '20 at 01:12
-
@Avdhoota, no, i tried it before, it couldn't help me increase the timeout – Ryan Nguyen Apr 28 '20 at 01:12
-
my issue came from server-side, we using cloudfront and it was limited at 30s – Ryan Nguyen Apr 28 '20 at 14:05
-
Finally, I found that the timeout was controlled by the server instead of the client-side. – Ryan Nguyen Aug 03 '20 at 03:15
1 Answers
1
You need to use the timeout operator. Since rxjs 5.5.2 you need to use the pipe method with lettable operators. And assuming you are using the HttpClient to make your requests, there is no need for a map(response => response.json()).
Like this:
import { timeout, catchError } from 'rxjs/operators'; import { of } from 'rxjs/observable/of';
http.get('https://example.com') .pipe( timeout(2000), catchError(e => { // do something on a timeout return of(null); }) )

Avdhoota
- 451
- 4
- 20
-
1do this way only decrease the timeout limit . it can't help me to increase timeout – Ryan Nguyen Apr 28 '20 at 01:07