NodeJS cannot start WebScocket stream

akshayhalasangi
Hello there team,
I'm trying to connect to the websocket using the NodeJS library but I'm getting the following error.
{"type":"error","target":{"domain":null,"_events":{},"_eventsCount":4,"_socket":null,"_ultron":null,"_closeReceived":false,"bytesReceived":0,"readyState":0,"supports":{"binary":true},"extensions":{},"_binaryType":"arraybuffer","_isServer":false,"url":"wss://ws.kite.trade/?api_key=0i3887nnqsdaadfytsq0un&access_token=ag0spuQ7padfa8DuOspNBcGXeWukp5Q58fgL&uid=1582540313380","protocolVersion":13}}
i'm not sure what I am doing wrong
  • sujith
    Can you paste complete code here?
    Please don't paste app or user-related tokens on public threads. If you have to share these details then you can private message us.
  • akshayhalasangi
    akshayhalasangi edited February 2020
    var ticker = new KiteTicker({
    api_key: "Key",
    access_token: "token"
    });

    console.log("this is called");
    // 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("error", onError);
    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 onError(err)
    {
    console.log(JSON.stringify(err));
    }

    function subscribe() {
    var items = [738561];
    ticker.subscribe(items);
    ticker.setMode(ticker.modeFull, items);
    }
  • sujith
    This code seems fine. Can you paste the complete stacktrace here?
    Have you implemented onError? Can you log the error?
  • sujith
    Where are you calling this? Can you let us know more about the setup and library version, node version?
Sign In or Register to comment.