[fix] destroy() websockets in case of an error

Not doing so caused websockets in `CLOSE_WAIT` to pile up and cause
proxy to exceed open file descriptor limit.
This commit is contained in:
Maciej Małecki 2012-07-24 16:30:51 +02:00
parent 13c34d09b2
commit 0d00b06af3

View File

@ -611,12 +611,17 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
// connections.
//
function proxyError (err) {
reverseProxy.end();
if (self.emit('webSocketProxyError', req, socket, head)) {
return;
}
reverseProxy.destroy();
socket.end();
process.nextTick(function () {
//
// Destroy the incoming socket in the next tick, in case the error handler
// wants to write to it.
//
socket.destroy();
});
self.emit('webSocketProxyError', req, socket, head);
}
//