在node.js中捕获“close”套接字事件

时间:2013-02-14 09:34:12

标签: apache node.js sockets mod-proxy

我在端口80上使用Apache。

Node.js服务器侦听端口1337,Apache通过他所有代理请求:

ProxyRequests off

ProxyPass /nodejs/ http://127.0.0.1:1337/ timeout=300 retry=0
ProxyPassReverse /nodejs/ http://127.0.0.1:1337/

和server.js:

var http = require("http");

http.createServer(function (req, res) {
    req.socket.on("close", function () {
        console.log("socket close");
    });
}).listen(1337);

问题:当用户中止连接时(在浏览器中停止请求,例如按Esc),node.js无法触发 socket.on(“close”)直到apache的超时为止活。

问题的解决方案是什么,除了将Apache放在node.js之外?

0 个答案:

没有答案
相关问题