-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.invalidIssues and PRs that are invalid.Issues and PRs that are invalid.netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.
Description
Version: 7.4
Platform: Linux DEV-PC 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Subsystem: http
This happens from node 4.x to 7.x as far as I've tested on MacOS and Ubuntu/Arch Linux with older/newer stack and software.
Example attached, shows that using domain name for HTTP request results in invalid socket _handle.fd
Usine createConnection directly gives a valid fd in both cases
I know that file descriptors in node are like black sheeps but is there something else that needs to be done to get a valid socket file descriptor or is this a genuine bug?
const http = require('http')
const net = require('net')
// this doesn't give valid fd handle
const r1 = http.get({ hostname: 'www.google.hr', port: 80 })
r1.on('socket', function(s)
{
console.log("socket fd invalid", s._handle.fd)
})
// this does give valid fd handle, notice that ip is used instead of domain name
const r2 = http.get({ hostname: '213.202.89.187', port: 80 })
r2.on('socket', function(s)
{
console.log("socket fd valid", s._handle.fd)
})
// this gives valid handle
const s1 = net.createConnection({ host: "www.google.com", port:80 }, function()
{
console.log("socket fd valid:", s1._handle.fd)
})
// this gives valid handle
const s2 = net.createConnection({ host: "213.202.89.187", port:80 }, function()
{
console.log("socket fd valid:", s2._handle.fd)
})Metadata
Metadata
Assignees
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.invalidIssues and PRs that are invalid.Issues and PRs that are invalid.netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.