简体   繁体   English

如何在 Angular 7 中增加超过 2 分钟的 HTTP 请求超时?

[英]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.我有一个请求需要 2 多分钟才能在后端准备数据并传输它。 The angular default time out for the HTTP request observable is 2 minutes. HTTP 请求可观察的角度默认超时为 2 分钟。 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!!我阅读并尝试了以下链接中建议的解决方案,但是如果您想将超时设置为小于 2 分钟,所有这些都可以正常工作,并且它们都不会增加超时时间!!

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

Can't have a timeout of over 2 minutes with this.http.get? this.http.get 的超时时间不能超过 2 分钟吗?

How to increase waiting time for HttpClient request in angular 5? 如何在 Angular 5 中增加 HttpClient 请求的等待时间?

How to set http call timeout in angularjs 4? 如何在 angularjs 4 中设置 http 调用超时?

Default and specific request timeout 默认和特定请求超时

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).我使用的是代理配置,代理的默认超时为 120 秒(2 分钟)。 So, if that's your case, simply define a higher value in the configuration.因此,如果您是这种情况,只需在配置中定义更高的值即可。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM