Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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.
  • Loading branch information
mmalecki committed Jul 24, 2012
1 parent 13c34d0 commit 0d00b06
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/node-http-proxy/http-proxy.js
Expand Up @@ -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();

process.nextTick(function () {
//
// Destroy the incoming socket in the next tick, in case the error handler
// wants to write to it.
//
socket.destroy();
});

socket.end();
self.emit('webSocketProxyError', req, socket, head);
}

//
Expand Down

0 comments on commit 0d00b06

Please sign in to comment.