问题
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
I am using NestJS (with express), does anyone know how to increase this timeout value using NestJS framework ?
Here is my initial question: Angular 9 http call with nestjs backend
-Jani
回答1:
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
回答2:
You can use some packages to apply a timeout as a middleware. https://www.npmjs.com/package/@nest-middlewares/connect-timeout
This package is just a wrapper of an express middleware, so be sure you use the express platform on your project.
来源:https://stackoverflow.com/questions/60787515/nestjs-rest-api-times-out-for-long-running-request