Node Js not getting response for multiple instruments pass in subscribe for websocket

ZS0082
when i am creating an array dynamically and sending it to subscribe I am not getting any response. But when I am sending a static array to subscribe I am getting a response. Pls help.

here is my code.
//ForWebSocket
exports.connectSocket = function(req,res) {
const { id } = req.params;
UserModels.getRequestToken(id, function(err, result){
var accessToken = result.access_token;
console.log("accessToken => "+ accessToken);
var ticker = new KiteTicker({
api_key: process.env.apiKey,
access_token: accessToken
});


ticker.autoReconnect(true, 10, 5)
ticker.connect();
ticker.on("connect", subscribe);
ticker.on("ticks", onTicks);

ticker.on("connect", function() {
console.log("connect");
});

ticker.on("noreconnect", function() {
console.log("noreconnect");
});

ticker.on("reconnecting", function(reconnect_interval, reconnections) {
console.log("Reconnecting: attempt - ", reconnections, " innterval - ", reconnect_interval);
});

function onTicks(ticks) {
console.log("Ticks 2 => ", ticks);
var data = ticks;
for (let index = 0; index < data.length; index++) {
var subscribRecords = new SubscribRecords(data[index]);
InstrumentsModels.saveSubscribRecords(subscribRecords),function(err,result){

};
}
}

<b class="Bold"> function subscribe() {
InstrumentsModels.getInstrumentsSelected(function(err,result){
var instrument= [];
//var items = [260105,256265,21490690,21490946,21491202];
for(var i =0; i < result.length; i++){
instrument.push(result[i].instrument_token);
}
ticker.subscribe(instrument);
ticker.setMode(ticker.modeFull, instrument);
});
}</b>

});
res.redirect('/');
}
  • sujith
    Did you set onError and check?
    Also, you can print the array that you are sending and check.
  • ZS0082
    we have tried above both but no error accrue. the token List print same when we pass both way dynamic and static.
Sign In or Register to comment.