Skip to content

Commit

Permalink
close websocket if proxyReq is closed before upgrade
Browse files Browse the repository at this point in the history
avoids leaving client sockets open when upstream
connections are rejected.
  • Loading branch information
minrk committed Sep 30, 2014
1 parent 7730548 commit c20aaac
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/http-proxy/passes/ws-incoming.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ var passes = exports;
);
// Error Handler
proxyReq.on('error', onOutgoingError);
proxyReq.on('response', function (res) {
// if upgrade event isn't going to happen, close the socket
// so we don't leave it hanging.
if (!res.upgrade) socket.end();
});

proxyReq.on('upgrade', function(proxyRes, proxySocket, proxyHead) {
proxySocket.on('error', onOutgoingError);
Expand Down

0 comments on commit c20aaac

Please sign in to comment.