mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Close outgoing ws if incoming ws emits error
Fixes #559, which contains a full reproduction recipe.
This commit is contained in:
parent
daad4703f3
commit
4c3ba74c4e
@ -88,10 +88,16 @@ var passes = exports;
|
||||
common.setupOutgoing(options.ssl || {}, options, req)
|
||||
);
|
||||
// Error Handler
|
||||
proxyReq.on('error', onError);
|
||||
proxyReq.on('error', onOutgoingError);
|
||||
|
||||
proxyReq.on('upgrade', function(proxyRes, proxySocket, proxyHead) {
|
||||
proxySocket.on('error', onError);
|
||||
proxySocket.on('error', onOutgoingError);
|
||||
// The pipe below will end proxySocket if socket closes cleanly, but not
|
||||
// if it errors (eg, vanishes from the net and starts returning
|
||||
// EHOSTUNREACH). We need to do that explicitly.
|
||||
socket.on('error', function () {
|
||||
proxySocket.end();
|
||||
});
|
||||
|
||||
common.setupSocket(proxySocket);
|
||||
|
||||
@ -106,7 +112,7 @@ var passes = exports;
|
||||
|
||||
return proxyReq.end(); // XXX: CHECK IF THIS IS THIS CORRECT
|
||||
|
||||
function onError(err) {
|
||||
function onOutgoingError(err) {
|
||||
if (clb) {
|
||||
clb(err, req, socket);
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user