Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

fix bug of socket CLOSE_WAIT #21

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/tunnel.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,20 @@ TunnelingAgent.prototype.createSocket = function createSocket(options, cb) {
function onConnect(res, socket, head) {
connectReq.removeAllListeners();
socket.removeAllListeners();
self.sockets[self.sockets.indexOf(placeholder)] = socket

if (res.statusCode === 200) {
assert.equal(head.length, 0);
debug('tunneling connection has established');
self.sockets[self.sockets.indexOf(placeholder)] = socket;
cb(socket);
} else {
debug('tunneling socket could not be established, statusCode=%d',
res.statusCode);
var error = new Error('tunneling socket could not be established, ' +
'statusCode=' + res.statusCode);
error.code = 'ECONNRESET';
cb(socket)
options.request.emit('error', error);
self.removeSocket(placeholder);
}
}

Expand Down