-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tls: add host and port info to ECONNRESET errors
Add more information to the "ECONNRESET" errors generated when the socket hang ups before establishing the secure connection. These kind of errors are really hard to troubleshoot without this info. PR-URL: #7476 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Yazhong Liu <[email protected]>
- Loading branch information
1 parent
74741fa
commit e2d3254
Showing
5 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const net = require('net'); | ||
const tls = require('tls'); | ||
|
||
const server = net.createServer((c) => { | ||
c.end(); | ||
}).listen(common.mustCall(() => { | ||
const port = server.address().port; | ||
|
||
tls.connect({ | ||
port: port, | ||
localAddress: common.localhostIPv4 | ||
}, common.localhostIPv4) | ||
.once('error', common.mustCall((e) => { | ||
assert.strictEqual(e.code, 'ECONNRESET'); | ||
assert.strictEqual(e.path, undefined); | ||
assert.strictEqual(e.host, undefined); | ||
assert.strictEqual(e.port, port); | ||
assert.strictEqual(e.localAddress, common.localhostIPv4); | ||
server.close(); | ||
})); | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const tls = require('tls'); | ||
const net = require('net'); | ||
|
||
common.refreshTmpDir(); | ||
|
||
const server = net.createServer((c) => { | ||
c.end(); | ||
}).listen(common.PIPE, common.mustCall(() => { | ||
tls.connect({ path: common.PIPE }) | ||
.once('error', common.mustCall((e) => { | ||
assert.strictEqual(e.code, 'ECONNRESET'); | ||
assert.strictEqual(e.path, common.PIPE); | ||
assert.strictEqual(e.port, undefined); | ||
assert.strictEqual(e.host, undefined); | ||
assert.strictEqual(e.localAddress, undefined); | ||
server.close(); | ||
})); | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const net = require('net'); | ||
const tls = require('tls'); | ||
|
||
const server = net.createServer((c) => { | ||
c.end(); | ||
}).listen(common.mustCall(() => { | ||
const port = server.address().port; | ||
|
||
const socket = new net.Socket(); | ||
|
||
tls.connect({ socket }) | ||
.once('error', common.mustCall((e) => { | ||
assert.strictEqual(e.code, 'ECONNRESET'); | ||
assert.strictEqual(e.path, undefined); | ||
assert.strictEqual(e.host, undefined); | ||
assert.strictEqual(e.port, undefined); | ||
assert.strictEqual(e.localAddress, undefined); | ||
server.close(); | ||
})); | ||
|
||
socket.connect(port); | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const net = require('net'); | ||
const tls = require('tls'); | ||
|
||
const server = net.createServer((c) => { | ||
c.end(); | ||
}).listen(common.mustCall(() => { | ||
const port = server.address().port; | ||
|
||
tls.connect(port, common.localhostIPv4) | ||
.once('error', common.mustCall((e) => { | ||
assert.strictEqual(e.code, 'ECONNRESET'); | ||
assert.strictEqual(e.path, undefined); | ||
assert.strictEqual(e.host, common.localhostIPv4); | ||
assert.strictEqual(e.port, port); | ||
assert.strictEqual(e.localAddress, undefined); | ||
server.close(); | ||
})); | ||
})); |