如何在 Angular 7 中增加超过 2 分钟的 HTTP 请求超时? [英] How to increase HTTP request timeout more than 2 minutes in Angular 7?

查看:41
本文介绍了如何在 Angular 7 中增加超过 2 分钟的 HTTP 请求超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个请求,在后端准备数据并传输它需要 2 分钟以上的时间.HTTP 请求可观察的角度默认超时为 2 分钟.知道如何增加默认超时吗?

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?

我阅读并尝试了以下链接中提出的解决方案,但如果您想将超时设置为小于 2 分钟,所有这些都可以正常工作,并且它们都无法增加超时时间!!

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

不能有this.http.get 超时超过 2 分钟?

如何增加 Angular 5 中 HttpClient 请求的等待时间?

如何在 angularjs 4 中设置 http 调用超时?

默认和特定请求超时

推荐答案

我在评论中没有收到您的回复,但我的开发机器上确实遇到了这个问题,也许您也遇到了这种情况.

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.

我使用的是 代理配置,以及代理的默认超时为 120 秒(2 分钟).因此,如果您是这种情况,只需在配置中定义一个更高的值即可.

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
  }
}

这篇关于如何在 Angular 7 中增加超过 2 分钟的 HTTP 请求超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆