jaggedsoft / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.
MIT License
1.58k stars 768 forks source link

balanceData error #835

Open HomeRobot opened 2 years ago

HomeRobot commented 2 years ago

My code is:

const config = require("./config/config") const Binance = require("node-binance-api")

let binance = new Binance().options({ APIKEY: config.APIKEY, APISECRET: config.APISECRET, useServerTime: true, reconnect: true, verbose: true })

binance.balance((error, balances) => { if ( error ) console.log(error)> console.log(balances) })

API keys are valid, IP added. When I try to run it, I got an error: [ 'balanceData error', {} ] 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:1116:5 at defaultTriggerAsyncIdScope (node:internal/async_hooks:463:18) at lookupAndConnect (node:net:1115:3) at Socket.connect (node:net:1053:5) at Object.connect (node:_tls_wrap:1660:13) at Agent.createConnection (node:https:146:22) at Agent.createSocket (node:_http_agent:343:26) at Agent.addRequest (node:_http_agent:294:10) at new ClientRequest (node:_http_client:319:16) { code: 'ERR_INVALID_ARG_VALUE' } {}

fagnersouza666 commented 2 years ago

waiting for correction

fagnersouza666 commented 2 years ago

jaggedsoft commented on 5 Sep 2018

problem is because useServerTime takes a second to kick in sometimes For you this method of serverTime should work, this will allow it to fire on startup

binance.useServerTime(() => binance.balance((error, balances) => { if ( error ) return console.error(error.body); console.log("balances()", balances); if ( typeof balances.BTC !== "undefined" ) console.log("BTC balance: ", balances.BTC.available); if ( typeof balances.ETH !== "undefined" ) console.log("ETH balance: ", balances.ETH.available); }) );

ghost commented 1 year ago

This is an error telling you to reveal your ip connection type. Please find out your ip address type (ipv4, ipv6 etc) (probably ipv4) and try with the parameter I wrote as family.

let binance = new Binance().options({
                                  APIKEY: config.APIKEY,
                                  APISECRET: config.APISECRET,
                                  family: 4,
                                  useServerTime: true,
                                  reconnect: true,
                                  verbose: true,

})