Open Sadmansamee opened 2 years ago
I have the same problem. It seems to be related to dns.lookup. I don't know how to solve it yet.
yeah, it works from my local, but creates issue whenever I deployed it on server.
@olegkamzin have you found any solution?
@Sadmansamee I have this problem only on version 18. On this version, the application does not run at all. On 17.9 everything works, only an error crashes at startup.
While I'm working like this)
Thanks after downgrading node version it works fine.
Error only happen with node.js 18.
Have you found any solution?
Any solution for this issue?
Any updates?
Downgrade your node version, this error only happens with node 18
That is ok for now, but not in the long run.
Any news about this error?
downgrade
I found a better solution than downgrade. At the Binance object constructor, you can specify the property 'family' in the options object, with 0, 4 or 6, as mentioned in the error, referring to IPv4+6, IPv4 and IPv6, respectively. The option default is false, that is incompatible with Node 18's dns lookup.
Is there any reason why the above solution still wasn't introduced into the code base?
I found a better solution than downgrade. At the Binance object constructor, you can specify the property 'family' in the options object, with 0, 4 or 6, as mentioned in the error, referring to IPv4+6, IPv4 and IPv6, respectively. The option default is false, that is incompatible with Node 18's dns lookup.
As suggested by @luiztools, it works. I use Node 18 and did modify the 'family' options to 4 which is IPV4(my internet provider support IPV4). You guys can try to change the number to 0, 4 or 6 Here is my sample code
const Binance = require('node-binance-api');
const binance = new Binance().options({
APIKEY: '<YOUR-APIKEY>',
APISECRET: '<YOUR-APISECRET>',
'family': 4,
});
async function main() {
binance.websockets.depthCache(['BNBBUSD'], (symbol, depth) => {
let bids = binance.sortBids(depth.bids);
let asks = binance.sortAsks(depth.asks);
console.info(symbol+" depth cache update");
console.info("bids", bids);
console.info("asks", asks);
console.info("best bid: "+binance.first(bids));
console.info("best ask: "+binance.first(asks));
console.info("last updated: " + new Date(depth.eventTime));
});
}
main();
I found a better solution than downgrade. At the Binance object constructor, you can specify the property 'family' in the options object, with 0, 4 or 6, as mentioned in the error, referring to IPv4+6, IPv4 and IPv6, respectively. The option default is false, that is incompatible with Node 18's dns lookup.
As suggested by @luiztools, it works. I use Node 18 and did modify the 'family' options to 4 which is IPV4(my internet provider support IPV4). You guys can try to change the number to 0, 4 or 6 Here is my sample code
const Binance = require('node-binance-api'); const binance = new Binance().options({ APIKEY: '<YOUR-APIKEY>', APISECRET: '<YOUR-APISECRET>', 'family': 4, }); async function main() { binance.websockets.depthCache(['BNBBUSD'], (symbol, depth) => { let bids = binance.sortBids(depth.bids); let asks = binance.sortAsks(depth.asks); console.info(symbol+" depth cache update"); console.info("bids", bids); console.info("asks", asks); console.info("best bid: "+binance.first(bids)); console.info("best ask: "+binance.first(asks)); console.info("last updated: " + new Date(depth.eventTime)); }); } main();
this solved the problem on my case using node v18.12.1
I found a better solution than downgrade. At the Binance object constructor, you can specify the property 'family' in the options object, with 0, 4 or 6, as mentioned in the error, referring to IPv4+6, IPv4 and IPv6, respectively. The option default is false, that is incompatible with Node 18's dns lookup.
As suggested by @luiztools, it works. I use Node 18 and did modify the 'family' options to 4 which is IPV4(my internet provider support IPV4). You guys can try to change the number to 0, 4 or 6 Here is my sample code
const Binance = require('node-binance-api'); const binance = new Binance().options({ APIKEY: '<YOUR-APIKEY>', APISECRET: '<YOUR-APISECRET>', 'family': 4, }); async function main() { binance.websockets.depthCache(['BNBBUSD'], (symbol, depth) => { let bids = binance.sortBids(depth.bids); let asks = binance.sortAsks(depth.asks); console.info(symbol+" depth cache update"); console.info("bids", bids); console.info("asks", asks); console.info("best bid: "+binance.first(bids)); console.info("best ask: "+binance.first(asks)); console.info("last updated: " + new Date(depth.eventTime)); }); } main();
this solved the problem on my case using node v18.12.1
this works with node v20
Whenever I try to call any API I get this error
TypeError [ERR_INVALID_ARG_VALUE]: The property 'options.family' must be one of: 0, 4, 6. Received false