mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Fix socket leaks when FIN packet isn't responded to
This commit is contained in:
parent
0d00b06af3
commit
24b84068ea
@ -500,8 +500,6 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
|
||||
}
|
||||
catch (ex) {
|
||||
detach();
|
||||
reverseProxy.incoming.socket.end();
|
||||
proxySocket.end();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -532,8 +530,6 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
|
||||
}
|
||||
catch (ex) {
|
||||
detach();
|
||||
proxySocket.end();
|
||||
socket.end();
|
||||
}
|
||||
});
|
||||
|
||||
@ -542,8 +538,10 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
|
||||
// from `reverseProxy` and `proxySocket`.
|
||||
//
|
||||
function detach() {
|
||||
proxySocket.destroySoon();
|
||||
proxySocket.removeListener('end', listeners.onIncomingClose);
|
||||
proxySocket.removeListener('data', listeners.onIncoming);
|
||||
reverseProxy.incoming.socket.destroySoon();
|
||||
reverseProxy.incoming.socket.removeListener('end', listeners.onOutgoingClose);
|
||||
reverseProxy.incoming.socket.removeListener('data', listeners.onOutgoing);
|
||||
}
|
||||
@ -553,7 +551,6 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
|
||||
// detach all event listeners.
|
||||
//
|
||||
proxySocket.on('end', listeners.onIncomingClose = function() {
|
||||
reverseProxy.incoming.socket.end();
|
||||
detach();
|
||||
|
||||
// Emit the `end` event now that we have completed proxying
|
||||
@ -565,7 +562,6 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
|
||||
// event listeners.
|
||||
//
|
||||
reverseProxy.incoming.socket.on('end', listeners.onOutgoingClose = function() {
|
||||
proxySocket.end();
|
||||
detach();
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user