对于长时间运行的请求,NestJS REST API 超时 [英] NestJS REST API times out for long running request

查看:301
本文介绍了对于长时间运行的请求,NestJS REST API 超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过长时间的调查,问题似乎是长时间运行的请求超时,并且在 NodeJS 中再次调用了端点.浏览器没有新的网络请求.我做了一些测试,2 分钟后再次调用端点.我读到 NodeJS 中 http 请求的默认超时时间为 2 分钟.

After lengthy investigations the problems seems to be that the long running request times out and the endpoint is called again in NodeJS. There is no new network request from browser. I made a few tests and after 2 mins the endpoint is invoked again. I read that the default timeout for the http requests in NodeJS in 2mins.

https://nodejs.org/docs/latest-v12.x/​​api/http.html#http_server_timeout

我正在使用 NestJS(带有 express),有没有人知道如何使用 NestJS 框架增加这个超时值?

I am using NestJS (with express), does anyone know how to increase this timeout value using NestJS framework ?

这是我最初的问题:带有 nestjs 后端的 Angular 9 http 调用

-贾尼

推荐答案

这似乎可以解决每个请求的问题.我不知道如何在服务器级别上做到这一点,但这对我来说已经足够了.

this seems to do the trick per request. I don't know how to do it on server level but this is enough for me.

req.setTimeout(300000); // 5 minutes

这篇关于对于长时间运行的请求,NestJS REST API 超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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