是否有办法让express.js服务器始终使用dns查找IPV4地址,而不是同时查找IPv4和IPV6地址?
就像我们在java中通过设置参数java.net.preferIPv4Stack=true来做到这一点一样。
当我的add正在进行出站服务调用时,我希望对传出请求执行此操作。我的应用程序使用请求npm包,它使用净npm包,它使用dns npm软件包。dns软件包有一个选项来设置IP家族,可以是4或6。如果我将它设置为4,我认为这会做我想做的事情。
现在的问题是,如何从我的应用程序中传递这个选项,以便在运行时应用到这个npm包。
发布于 2017-09-07 12:09:52
我不得不这样做,以迫使DNS查找仅查找IPv4地址,而不是IPv6地址。
import Request from 'request';
export class SoapUtility extends Utility
{
constructor(options) {
super();
otherCode = otherCode;
this.request = Request;
};
requestMainframe(args, callback)
{
this.request.post({
url: this.endpoints.userLookup,
method: 'POST',
family : 4,
headers: {
'Content-Type': 'text/xml',
"Authorization": `Basic ${creds}`
},
body: requestBody,
rejectUnauthorized: false,
}, (error, response, body) => {
callback(error, null);
});
}
}
https://stackoverflow.com/questions/46057684
复制相似问题