#Changing HTTP Server timeout limits

5 messages · Page 1 of 1 (latest)

cedar stump
#

Hi all,
I want to be able to set the timeouts for http requests in our nestjs server. Currently any request that takes longer than ~300,000ms (5 minutes) appears to timeout.

The use-case is that I have AI operations/requests that may take longer than 5 minutes.

I've done some research and found this maybe something related to express and a default timeout interval set that we can override maybe like this:

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  const server = await app.listen(process.env.PORT || 3000);
  const httpServer = server.getHttpServer();

  httpServer.setTimeout(20 * 60 * 1000); // 20 minutes
  // Set keep-alive timeout (for connection reuse)
  httpServer.keepAliveTimeout = 65000; // 65 seconds (should be > load balancer timeout) 
  // Set headers timeout (should be slightly > keepAliveTimeout)
  httpServer.headersTimeout = 66000; // 66 seconds

However I want to keep the default 5 minutes for all request and just change for specific controllers/modules.

#

Changing HTTP Server timeout limits

wicked bluff
#

hi

urban bay
#

If you have such long response delays, it would be better to implement streaming responses via websockets