mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
memory leak fix in closing of the scokets
This commit is contained in:
parent
013cb2e0c2
commit
2055d0c8ec
@ -551,24 +551,31 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
|
||||
reverseProxy.incoming.socket.removeListener('data', listeners.onOutgoing);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// If the incoming `proxySocket` socket closes, then
|
||||
// detach all event listeners.
|
||||
//
|
||||
proxySocket.on('end', listeners.onIncomingClose = function() {
|
||||
listeners.onIncomingClose = function() {
|
||||
reverseProxy.incoming.socket.destroy();
|
||||
detach();
|
||||
|
||||
// Emit the `end` event now that we have completed proxying
|
||||
self.emit('websocket:end', req, socket, head);
|
||||
});
|
||||
self.emit('websocket:end', req, socket, head);
|
||||
}
|
||||
|
||||
//
|
||||
// If the `reverseProxy` socket closes, then detach all
|
||||
// event listeners.
|
||||
//
|
||||
reverseProxy.incoming.socket.on('end', listeners.onOutgoingClose = function() {
|
||||
detach();
|
||||
});
|
||||
//
|
||||
listeners.onOutgoingClose = function() {
|
||||
proxySocket.destroy();
|
||||
detach();
|
||||
}
|
||||
|
||||
proxySocket.on('end', listeners.onIncomingClose);
|
||||
proxySocket.on('close', listeners.onIncomingClose);
|
||||
reverseProxy.incoming.socket.on('end', listeners.onOutgoingClose);
|
||||
reverseProxy.incoming.socket.on('close', listeners.onOutgoingClose);
|
||||
}
|
||||
|
||||
function getPort (port) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user