如何在Angular 7中将HTTP请求超时增加2分钟以上? [英] How to increase HTTP request timeout more than 2 minutes in Angular 7?
问题描述
我有一个超过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
How to set http call timeout in angularjs 4?
推荐答案
我在评论中没有收到您的答复,但是我的开发机上遇到了这个确切的问题,也许您也正在发生
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中将HTTP请求超时增加2分钟以上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!