我在客户端使用 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/