简体   繁体   English

当我不回复请求时如何防止快递发送“502 Bad Gateway”?

[英]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. 对于具有快速4服务器的特殊用例(强制客户端,不响应503状态代码重复请求)我根本不需要响应客户端请求。

But Express sends a 502 Bad Gateway after apr. 但是Express在apr之后发送了一个502 Bad Gateway。 2 minutes, when I just omit to send a result. 2分钟,我只是省略发送结果。 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(); 你可以使用res.end(); . That will end the request. 这将结束请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Node.js/Express.js/consign(): 默认请求有效 ("/") 但 ("/tasks") 返回 502:Bad Gateway - Node.js/Express.js/consign(): default request works ("/") but ("/tasks") returns a 502:Bad Gateway 连接到通过 Nginx 运行 express 的 Nodejs 应用程序时出现 502 Bad Gateway - 502 Bad Gateway when connecting to Nodejs app running express through Nginx 到机器人的POST时出现502(错误网关) - 502(Bad gateway) when doing a POST to the bot 上传文件时 Nginx 502 Bad Gateway - Nginx 502 Bad Gateway when uploading files 为什么收到:502错误的网关? - Why I receive: 502 Bad Gateway? 部署后 AWS 弹性 beanstalk Express 服务 502 Bad Gateway - AWS elastic beanstalk Express service 502 Bad Gateway after deployment Passport.js express google oauth 502 nginx 上的网关错误 - Passport.js express google oauth 502 Bad Gateway on nginx 502 Bad Gateway在Elastic Beanstalk上部署Express Generator模板 - 502 Bad Gateway Deploying Express Generator Template on Elastic Beanstalk 使用docker-compose的节点express返回502错误的网关 - node express with docker-compose returns 502 bad gateway Nodejs 502 Bad Gateway在Elastic Beanstalk AWS上部署Express - Nodejs 502 Bad Gateway Deploying Express on Elastic Beanstalk AWS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM