It looks like you're new here. If you want to get involved, click one of these buttons!
const fs = require("fs");
var access_token = fs.readFileSync("./all_keys/access_token.txt").toString();
var api_key_txt = fs.readFileSync("./all_keys/api_key_only.txt").toString();
var KiteTicker = require("kiteconnect").KiteTicker;
var ticker = new KiteTicker({
api_key: api_key_txt,
access_token: access_token
});
// set autoreconnect with 10 maximum reconnections and 5 second interval
ticker.autoReconnect(true, 10, 5)
ticker.connect();
ticker.on("ticks", onTicks);
ticker.on("connect", subscribe);
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", ticks);
}
function subscribe() {
var items = [14451970];
ticker.subscribe(items);
ticker.setMode(ticker.modeFull, items);
}
Either your
api_key
oraccess_token
is incorrect.So, connection is not getting established.Re-check the same.Really sorry man mistake when writing to file for access token.
Thanks