开发者

Long polling getting timed out from browser

I'm trying to serve long polling requests for 60 secs u开发者_运维百科sing node.js. The problem I'm facing is, the browser is getting timed out. The same setup is working for 30 secs. Can anybody suggest how to achieve this? Using JQuery as JS framework.

Thanks...


By default, node.js has a 60 second timeout for TCP/IP connections. You can get around this by explicitly setting the timeout. Here's a quick example:

http.createServer(function (req, res) {
    // Connection now times out after 120 seconds
    req.connection.setTimeout(120000);
    // ... TODO: server logic ...
}).listen(8000);

You can tell node to hold the connection open indefinitely by setting to the timeout to 0. Also, note that the default 60 second timeout applies to all socket connections in addition to TCP/IP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜