在express / node.js中设置和处理http超时

时间:2021-10-17 19:01:33

There's very little documentation and reasoning on how to handle and set http timeouts in express.

关于如何在express中处理和设置http超时的文档和推理很少。

I think they can be set via:

我认为他们可以通过以下方式设置:

req.connection.setTimeout(600000);

Update: I got this working to set it, confirmed.

更新:我确定了这个设置它。

But after this limit, the server comes back with "No data received". I tried this module express-timeout and it didn't work.

但是在此限制之后,服务器将返回“未收到数据”。我试过这个模块快速超时,它没有用。

Ideas?

想法?

1 个解决方案

#1


3  

What behavior do you want when timeout is exceeded?

超时超时时您想要什么行为?

Here's the documentation for timeout: http://www.senchalabs.org/connect/timeout.html

这是超时的文档:http://www.senchalabs.org/connect/timeout.html

Are you sure you don't want something like sockets.io that would enable connections to be kept alive and reinitiated as needed?

你确定你不想要像sockets.io这样的东西,它可以使连接保持活力并根据需要重新启动吗?

#1


3  

What behavior do you want when timeout is exceeded?

超时超时时您想要什么行为?

Here's the documentation for timeout: http://www.senchalabs.org/connect/timeout.html

这是超时的文档:http://www.senchalabs.org/connect/timeout.html

Are you sure you don't want something like sockets.io that would enable connections to be kept alive and reinitiated as needed?

你确定你不想要像sockets.io这样的东西,它可以使连接保持活力并根据需要重新启动吗?