https - 在 Angular2 http 模块中增加一个 http get 请求连接超时

标签 https timeout

我在客户端使用 Angular2,在后端使用 Node。我试图保持 https 连接打开,直到它在 4 小时内超时。

在后端我试过,调用它但它仍然默认超时 2 分钟

request.timeout(1000 * 60 * 60 * 4, function(){})

因为我使用 Angular2 http 模块。我尝试在 http 请求中使用超时方法如下,此超时默认为 2 分钟:

return this.http.get(this.URL, {search : params, withCredentials: true}) .map(res => res.json()) .timeout(1000 * 60 * 60 * 4) .catch(this.handleError);

将 https 请求连接从默认的 2 分钟增加到 4 小时的任何其他建议

最佳答案

以下是一些建议:

  • 等待 4 小时的响应不是一个好的设计。尝试更改后端以获得更快的响应

  • 在项目的 web.config 文件中添加 requestTimeout 解决了我的问题

    <system.webServer>
    <handlers>
    <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore requestTimeout="00:10:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
    </system.webServer>
    

关于https - 在 Angular2 http 模块中增加一个 http get 请求连接超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45755198/

相关文章:

https - 动态客户关系管理 : HTTPS SSL

iis - 对于 IE/XP 支持,使用通配符 SSL 证书是否安全?

.htaccess - 使用 .htaccess 控制某些页面上的 HTTPS

c# - 使用 async await 处理 Web 请求的超时

java - InetAddress获取IP不一致

php - 使用 Silex 框架加密数据

javax.net.ssl.SSLKeyException : [Security:090477]Certificate chain received from intranet. xxx.com

php - 有没有可靠的方法来避免 PHP 超时?

javascript - 如何捕获浏览器超时并执行我自己的错误消息?

c# - Windows 服务在 Windows 关闭时的行为如何?