Ole*_*leg 2 javascript websocket node.js binance
当使用node-binance-api,即订单簿时,出现此错误。我不知道如何解决。经验还不够...
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
Run Code Online (Sandbox Code Playgroud)
在之前的版本中,node js 正在运行,但也出现错误。然而,它奏效了。
(node:6424) [DEP0153] DeprecationWarning: Type coercion of dns.lookup options is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
Run Code Online (Sandbox Code Playgroud)
根据问题评论中的奥列格链接,解决方案现在说明如下:链接
简而言之,Node 18 已弃用dns.lookup,dnsPromises.lookup选项类型为强制。关联
创建授权的binance对象时需要注明IP地址版本。该选项默认为 false,即与 Node 18 的 dns 查找不兼容。
const binance = new Binance().options({
APIKEY: '<YOUR-APIKEY>',
APISECRET: '<YOUR-APISECRET>',
'family': 4,
});
Run Code Online (Sandbox Code Playgroud)
并来自节点文档:
"family | 记录系列。必须为 4、6 或 0。出于向后兼容性原因,'IPv4' 和 'IPv6' 分别解释为 4 和 6。值 0 表示同时返回 IPv4 和 IPv6 地址。默认: 0"
| 归档时间: |
|
| 查看次数: |
3418 次 |
| 最近记录: |