最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - TypeError [ERR_INVALID_ARG_VALUE]: The property 'options.family' must be one of: 0, 4, 6. Received

matteradmin10PV0评论

When using the node-binance-api, namely the order book, this error appears. I don't know how to solve it. Experience is not enough...

TypeError [ERR_INVALID_ARG_VALUE]: The property 'options.family' must be one of: 0, 4, 6. Received false
        at lookup (node:dns:143:7)
        at node:net:1082:5
        at defaultTriggerAsyncIdScope (node:internal/async_hooks:463:18)
        at lookupAndConnect (node:net:1081:3)
        at Socket.connect (node:net:1019:5)
        at Object.connect (node:_tls_wrap:1660:13)
        at Agent.createConnection (node:https:142:22)
        at Agent.createSocket (node:_http_agent:343:26)
        at Agent.addRequest (node:_http_agent:294:10)
        at new ClientRequest (node:_http_client:311:16) {
      code: 'ERR_INVALID_ARG_VALUE'
    }
    
    Node.js v18.0.0

code that doesn't work

On the previous version, node js was running, but also with an error. However, it worked.

(node:6424) [DEP0153] DeprecationWarning: Type coercion of dns.lookup options is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)

When using the node-binance-api, namely the order book, this error appears. I don't know how to solve it. Experience is not enough...

TypeError [ERR_INVALID_ARG_VALUE]: The property 'options.family' must be one of: 0, 4, 6. Received false
        at lookup (node:dns:143:7)
        at node:net:1082:5
        at defaultTriggerAsyncIdScope (node:internal/async_hooks:463:18)
        at lookupAndConnect (node:net:1081:3)
        at Socket.connect (node:net:1019:5)
        at Object.connect (node:_tls_wrap:1660:13)
        at Agent.createConnection (node:https:142:22)
        at Agent.createSocket (node:_http_agent:343:26)
        at Agent.addRequest (node:_http_agent:294:10)
        at new ClientRequest (node:_http_client:311:16) {
      code: 'ERR_INVALID_ARG_VALUE'
    }
    
    Node.js v18.0.0

code that doesn't work

On the previous version, node js was running, but also with an error. However, it worked.

(node:6424) [DEP0153] DeprecationWarning: Type coercion of dns.lookup options is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
Share Improve this question asked Apr 27, 2022 at 17:57 OlegOleg 291 silver badge2 bronze badges 2
  • As far as I understand , it is related to this nodejs/api/… – Oleg Commented Apr 27, 2022 at 17:59
  • github./jaggedsoft/node-binance-api/issues/819 – Oleg Commented Apr 27, 2022 at 18:02
Add a ment  | 

1 Answer 1

Reset to default 9

Following Oleg's links from the question ments, the solution is now stated here: link

In short, Node 18 deprectaited dns.lookup and dnsPromises.lookup options type coercion. link

The IP address version needs to be stated when creating an authorized binance object. The option default is false, that is inpatible with Node 18's dns lookup.

const binance = new Binance().options({
  APIKEY: '<YOUR-APIKEY>',
  APISECRET: '<YOUR-APISECRET>',
  'family': 4,
});

And from the node docs:

"family | The record family. Must be 4, 6, or 0. For backward patibility reasons,'IPv4' and 'IPv6' are interpreted as 4 and 6 respectively. The value 0 indicates that IPv4 and IPv6 addresses are both returned. Default: 0"

Post a comment

comment list (0)

  1. No comments so far