Skip to content

Commit c20aaac

Browse files
committed
close websocket if proxyReq is closed before upgrade
avoids leaving client sockets open when upstream connections are rejected.
1 parent 7730548 commit c20aaac

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: lib/http-proxy/passes/ws-incoming.js

+5
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ var passes = exports;
8989
);
9090
// Error Handler
9191
proxyReq.on('error', onOutgoingError);
92+
proxyReq.on('response', function (res) {
93+
// if upgrade event isn't going to happen, close the socket
94+
// so we don't leave it hanging.
95+
if (!res.upgrade) socket.end();
96+
});
9297

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

0 commit comments

Comments
 (0)