Open bcfsunali opened 3 years ago
It might be worthwhile to turn on automatic exception reporting, this throws a catastrophic error on an unhandled failure which often gives more information on the root cause of this issue
process.on( 'unhandledRejection', async ( reason, p ) => { console.log( 'Unhandled Rejection at:', p, 'reason:', reason ); process.exit(1);} );
On Mon, Dec 21, 2020 at 7:16 AM bcfsunali notifications@github.com wrote:
Hi Can someone help me, please
The library is working fine, but when I add more than 15 user accounts I'm getting this error, can you please help me to fix this issue, please. Error
/var/www/api/nodejs/futures/node_modules/node-binance-api/node-binance-api.js:902 const queryParams = streams.join( '/' ); ^
TypeError: Cannot read property 'join' of undefined Code
async function WS() { const Binance = require('node-binance-api'); const dbConnection = require("./connection");
var sqltt = 'SELECT * from auto_trading WHERE futures=1'; BceConnection.query(sqltt, async function(err, result) { if (err) throw err; numRows = result.length; console.log( 'numRows :' , numRows);
for(let x=0, len=numRows; x<len; x++){
FApikey= result[x].futures_api; FSecret= result[x].futures_secret;
const binance = new Binance(); binance.options({ APIKEY: await FApikey(FuturesApikey), APISECRET: await FSecret(FuturesSecret), reconnect: true, useServerTime: true });
function balance_update(data) { const util = require('util') console.log('balance_update :',util.inspect(data, {showHidden: false, depth: null})); }
function execution_update(data) { const util = require('util') var arr = util.inspect(data, {showHidden: false, depth: null}); console.log('execution_update :',arr); }
}
}
binance.websockets.userFutureData(balance_update, execution_update);
} }); }
WS();
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jaggedsoft/node-binance-api/issues/545, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAVXYAF2MX6F6EVPUMGBXLSV3R2FANCNFSM4VDYIGYQ .
It seems to me that this is not a problem in 15 or 16 users, but in one invalid apiKey / apiSecret. And check that you have the latest version of "node-binance-api": "^ 0.12.4", where the server crash was fixed.
Hi after long time of execution (4-5 hours maybe) i have the same problem than @bcfsunali
SECRET_PATH/node_modules/node-binance-api/node-binance-api.js:924
const queryParams = streams.join( '/' );
^
TypeError: Cannot read property 'join' of undefined
at futuresSubscribe (SECRET_PATH/node_modules/node-binance-api/node-binance-api.js:924:37)
at SECRET_PATH/node_modules/node-binance-api/node-binance-api.js:5228:42
at Request._callback (SECRET_PATH/node_modules/node-binance-api/node-binance-api.js:186:29)
at self.callback (SECRET_PATH/node_modules/request/request.js:185:22)
at Request.emit (events.js:315:20)
at Request.onRequestError (SECRET_PATH/node_modules/request/request.js:877:8)
at ClientRequest.emit (events.js:315:20)
at TLSSocket.socketErrorListener (_http_client.js:467:9)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:100:8)
And i have the lastest version latest version "node-binance-api": "^ 0.12.4"
but my binance is on test: true
possible it was that ?
I have launch an other test with more trace, i will keep you informed.
const pry = require('pryjs');
const Binance = require('node-binance-api');
dotenv.config();
const binance = new Binance().options({
APIKEY: process.env.APIKEY,
APISECRET: process.env.APISECRET,
test: true,
reconnect: true
});
async function main() {
const newMarginSignal = (res) => {
console.log(res);
};
const newSubscribedSignal = (res) => {
console.log(res);
};
const newAccountSignal = (res) => {
console.log(res);
};
const newOrderSignal = (res) => {
console.log(res);
};
binance.websockets.userFutureData(
newMarginSignal,
newAccountSignal,
newOrderSignal,
newSubscribedSignal
);
}
main();
after 2 hours of execution i have this:
node websocketStayConnected.js
rZqPps4xfHY0xBikrz1BL4UQSSGWbgm... [Function: userFutureDataHandler] { reconnect: [Function: reconnect] }
rZqPps4xfHY0xBikrz1BL4UQSSGWbgm...
[ 'Unexpected userFutureData: listenKeyExpired' ]
[ 'Unexpected userFutureData: listenKeyExpired' ]
Hi, clcreuso. Have you solved the problem with the "test: true" option? I have the same problem.
Uncaught Exception...
TypeError: Cannot read property 'join' of undefined
at futuresSubscribe (C:\Users\Александр\node_modules\node-binance-api\node-binance-api.js:924:37)
at C:\Users\Александр\node_modules\node-binance-api\node-binance-api.js:5228:42
at Request._callback (C:\Users\Александр\node_modules\node-binance-api\node-binance-api.js:187:63)
at Request.self.callback (C:\Users\Александр\node_modules\request\request.js:185:22)
at Request.emit (events.js:315:20)
at Request.
@maxah
Hi,
This is a very occasional error, i have not find why streams
is undefined.
But I am still looking for a solution on this bug, I will keep you informed.
Leave me a message if you find something ;-)
@maxah
Look my last PR. I make my reconnection manually, it's fix the error on streams.join
.
The error of streams.join
comes from here (if we have an error):
@jaggedsoft what we can do ? if (error) reconnect();
is good ?
And i think this line are false:
It should be url
instead of fapi
, right?
I faced this problem too, when test: true
, with using futureUserData stream.
facing the same issue. Any temporary workaround?
I have made my own library now, but if i remember the probleme was here for userFutureData
.
https://github.com/jaggedsoft/node-binance-api/blob/8bad385c70e4a3f9252fc203f5500c1976d0c9ea/node-binance-api.js#L5277 https://github.com/jaggedsoft/node-binance-api/blob/8bad385c70e4a3f9252fc203f5500c1976d0c9ea/node-binance-api.js#L5292
Binance.options.listenFutureKey
is the stream
var and is undefined
Yes is that the error in apiRequest is not catch you need to catch it when append and rerty after few seconds
Did anyone fix it? It seems I'm still having problems on last version with multiple subscriptions.
Thanks to @raricy
@jaggedsoft you didn't push in the stable version this PR ?
use this :
if ( error ) {
if ( error.code && error.code === 'ESOCKETTIMEDOUT' )
return reconnect();
else if ( error.body ) {
subscribed_callback( JSON.parse( error.body ) );
return;
}
}
must i use reconnect at true ?
after 2 hours of execution i have this:
node websocketStayConnected.js rZqPps4xfHY0xBikrz1BL4UQSSGWbgm... [Function: userFutureDataHandler] { reconnect: [Function: reconnect] } rZqPps4xfHY0xBikrz1BL4UQSSGWbgm... [ 'Unexpected userFutureData: listenKeyExpired' ] [ 'Unexpected userFutureData: listenKeyExpired' ]
Hi for this Error in expiration you need send a requestes ever 3 minutes for example to this endpoind in PUT request -> /fapi/v1/listenKey for keep the listenkey alive
after 2 hours of execution i have this:
node websocketStayConnected.js rZqPps4xfHY0xBikrz1BL4UQSSGWbgm... [Function: userFutureDataHandler] { reconnect: [Function: reconnect] } rZqPps4xfHY0xBikrz1BL4UQSSGWbgm... [ 'Unexpected userFutureData: listenKeyExpired' ] [ 'Unexpected userFutureData: listenKeyExpired' ]
Hi for this Error in expiration you need send a requestes ever 3 minutes for example to this endpoind in PUT request -> /fapi/v1/listenKey for keep the listenkey alive
The lib doesn't take care of this alone? I have to manage it myself?
Add 'family': 4, I solved this error with this solution:
const binance = new Binance().options({ APIKEY: '<YOUR-APIKEY>', APISECRET: '<YOUR-APISECRET>', 'family': 4, });
BTW, to avoid this Uncaught Exception errors like (because not catched by author):
const queryParams = streams.join( '/' );
TypeError: Cannot read property 'join' of undefined
We can use this instead:
process.on('uncaughtException', (error) => {
if (error instanceof TypeError) {
console.error('Uncaught Exception - ', error);
}
});
Hi Can someone help me, please
The library is working fine, but when I add more than 15 user accounts I'm getting this error, can you please help me to fix this issue, please.
Error
/var/www/api/nodejs/futures/node_modules/node-binance-api/node-binance-api.js:902 const queryParams = streams.join( '/' ); ^
TypeError: Cannot read property 'join' of undefined
Code
async function WS() { const Binance = require('node-binance-api'); const dbConnection = require("./connection");
const binance = new Binance(); binance.options({ APIKEY: await FApikey(FuturesApikey), APISECRET: await FSecret(FuturesSecret), reconnect: true, useServerTime: true });
function balance_update(data) { const util = require('util') console.log('balance_update :',util.inspect(data, {showHidden: false, depth: null})); }
function execution_update(data) { const util = require('util') var arr = util.inspect(data, {showHidden: false, depth: null}); console.log('execution_update :',arr); }
}
}
binance.websockets.userFutureData(balance_update, execution_update);
} });
}
WS();