简体   繁体   English

如何在Node.js中执行DNS查找

[英]How is DNS lookup performed in nodejs

We are facing a challenge with AWSlambda on node js, where DNS.resolve vs. dns.lookup are giving different results. 我们在节点js上使用AWSlambda面临挑战,其中DNS.resolve与dns.lookup给出不同的结果。 Where former faulting more than latter. 前者的缺点比后者多。 And http.client also fails with almost same frequency. 而且http.client也几乎以相同的频率失败。 I'm interested in understanding, how http module handles DNS lookup. 我有兴趣了解http模块如何处理DNS查找。

http.get() calls lookupAndConnect() in net.js which then calls lookup() in dns.js which then calls cares.getaddrinfo() which is in native code which calls uv_getaddrinfo() which has various platform implementations. http.get()调用lookupAndConnect()中net.js然后调用lookup()中dns.js然后调用cares.getaddrinfo()其是在它调用本机代码uv_getaddrinfo()其具有不同的平台实现。 Here are links to the windows and unix implementations. 这是WindowsUnix实现的链接。 The source is all on github for you to analyze. 源码全部在github上供您分析。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM