node-binance-api icon indicating copy to clipboard operation
node-binance-api copied to clipboard

Getting issue ERR_INVALID_ARG_VALUE

Open Sadmansamee opened this issue 3 years ago • 18 comments

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

2022-04-26T16:02:13.318271+00:00 app[web.1]:     at lookup (node:dns:143:7)
2022-04-26T16:02:13.318271+00:00 app[web.1]:     at node:net:1082:5
2022-04-26T16:02:13.318272+00:00 app[web.1]:     at defaultTriggerAsyncIdScope (node:internal/async_hooks:463:18)
2022-04-26T16:02:13.318273+00:00 app[web.1]:     at lookupAndConnect (node:net:1081:3)
2022-04-26T16:02:13.318273+00:00 app[web.1]:     at Socket.connect (node:net:1019:5)
2022-04-26T16:02:13.318273+00:00 app[web.1]:     at Object.connect (node:_tls_wrap:1660:13)
2022-04-26T16:02:13.318274+00:00 app[web.1]:     at Agent.createConnection (node:https:142:22)
2022-04-26T16:02:13.318274+00:00 app[web.1]:     at Agent.createSocket (node:_http_agent:343:26)
2022-04-26T16:02:13.318274+00:00 app[web.1]:     at Agent.addRequest (node:_http_agent:294:10)
2022-04-26T16:02:13.318275+00:00 app[web.1]:     at new ClientRequest (node:_http_client:311:16)
2022-04-26T16:02:13.318275+00:00 app[web.1]:     at Object.request (node:https:352:10)
2022-04-26T16:02:13.318275+00:00 app[web.1]:     at Object.<anonymous> (/app/node_modules/agent-base/patch-core.js:25:22)
2022-04-26T16:02:13.318276+00:00 app[web.1]:     at Object.request (/app/node_modules/socks-proxy-agent/node_modules/agent-base/patch-core.js:23:20)
2022-04-26T16:02:13.318277+00:00 app[web.1]:     at Request.start (/app/node_modules/request/request.js:751:32)
2022-04-26T16:02:13.318277+00:00 app[web.1]:     at Request.end (/app/node_modules/request/request.js:1505:10)
2022-04-26T16:02:13.318278+00:00 app[web.1]:     at end (/app/node_modules/request/request.js:564:14)
2022-04-26T16:02:13.318278+00:00 app[web.1]:     at Immediate.<anonymous> (/app/node_modules/request/request.js:578:7)
2022-04-26T16:02:13.318278+00:00 app[web.1]:     at process.processImmediate (node:internal/timers:471:21) {
2022-04-26T16:02:13.318279+00:00 app[web.1]:   code: 'ERR_INVALID_ARG_VALUE'
2022-04-26T16:02:13.318281+00:00 app[web.1]: } TypeError [ERR_INVALID_ARG_VALUE]: The property 'options.family' must be one of: 0, 4, 6. Received false at 4/26/2022, 4:02:13 PM in prod

Sadmansamee avatar Apr 26 '22 16:04 Sadmansamee

I have the same problem. It seems to be related to dns.lookup. I don't know how to solve it yet.

olegkamzin avatar Apr 27 '22 16:04 olegkamzin

yeah, it works from my local, but creates issue whenever I deployed it on server.

Sadmansamee avatar Apr 28 '22 13:04 Sadmansamee

@olegkamzin have you found any solution?

Sadmansamee avatar May 01 '22 05:05 Sadmansamee

@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. Снимок экрана 2022-05-01 в 14 59 07 While I'm working like this)

olegkamzin avatar May 01 '22 12:05 olegkamzin

Thanks after downgrading node version it works fine.

Sadmansamee avatar May 01 '22 12:05 Sadmansamee

Error only happen with node.js 18.

lpoirothattermann avatar May 06 '22 14:05 lpoirothattermann

Have you found any solution?

ptravassos avatar May 12 '22 13:05 ptravassos

Any solution for this issue?

Silvano-789 avatar Jun 22 '22 04:06 Silvano-789

Any updates?

cmartin81 avatar Jul 08 '22 12:07 cmartin81

Downgrade your node version, this error only happens with node 18

lpoirothattermann avatar Jul 08 '22 12:07 lpoirothattermann

That is ok for now, but not in the long run.

cmartin81 avatar Jul 08 '22 13:07 cmartin81

Any news about this error?

luiztools avatar Aug 14 '22 23:08 luiztools

downgrade

Sadmansamee avatar Aug 15 '22 05:08 Sadmansamee

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.

luiztools avatar Aug 16 '22 16:08 luiztools

Is there any reason why the above solution still wasn't introduced into the code base?

nichitagutu avatar Sep 09 '22 10:09 nichitagutu

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();

naimayz avatar Sep 11 '22 07:09 naimayz

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

Alphadan28 avatar Nov 27 '22 16:11 Alphadan28

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

YoleYu avatar Jul 27 '23 07:07 YoleYu