简体   繁体   中英

How to prevent express from sending “502 Bad Gateway” when I don't answer a request?

For a special use case with an express 4 server (forcing a client, that doesn't respond to 503 status code repeat a request) I need to not respond to a client request at all.

But Express sends a 502 Bad Gateway after apr. 2 minutes, when I just omit to send a result. How can I achieve this?

I tried to catch the timeout, but that doesn't help:

app.use((req, res, next) => {
  if (!req.timedout) {
    next();
    return;
  }

  console.log('Timeout!')
});

Tell me if I didn't understand the question correctly...

You can use res.end(); . That will end the request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM