You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
consthttp=require('http')constnet=require('net')// this doesn't give valid fd handleconstr1=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 nameconstr2=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 handleconsts1=net.createConnection({host: "www.google.com",port:80},function(){console.log("socket fd valid:",s1._handle.fd)})// this gives valid handleconsts2=net.createConnection({host: "213.202.89.187",port:80},function(){console.log("socket fd valid:",s2._handle.fd)})
The text was updated successfully, but these errors were encountered:
mscdex
added
domain
Issues and PRs related to the domain subsystem.
net
Issues and PRs related to the net subsystem.
http
Issues or PRs related to the http subsystem.
and removed
domain
Issues and PRs related to the domain subsystem.
labels
Jan 24, 2017
Not a bug - and it couldn't be, socket._handle.fd is internal and just for debugging.
What happens is that the DNS query is still in flight and the TCP connection hasn't been set up yet. Listen for the 'connect' event on the socket and only then inspect the .fd property.
in #8974 _handle.fd is presented as it is expected to be used even though it is internal
and this solution is a no go when one wants to set TCP_KEEPINTVL and TCP_KEEPCNT on that socket since it has to be set before connect so that connect is not hanging in specific cases (https://github.com/hertzg/node-net-keepalive)
I guess I can only resolve domain up front and then make a request as a workaround, yuck
Thanks nevertheless
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?
The text was updated successfully, but these errors were encountered: