sensex data is not coming of websocket #node js


  • const WebSocketV2 = require("../angleone/angleone_websocket");

    var symbolResponse = {
    SENSEX: {
    Price: 0,
    Prev_Close: 0,
    Qty: 0,
    },

    };
    var derivativesResponse = {};

    process.on("message", function (msg) {
    console.log("=============================mggggggg", msg);
    if (msg.action === "initiate") {
    let web_socket = new WebSocketV2({
    jwttoken: msg?.data?.access_token,
    apikey: msg?.data?.api_key,
    clientcode: msg?.data?.client_code,
    feedtype: msg?.data?.feed_token,
    });

    web_socket
      .connect()
      .then(() => {
        let json_req1 = {
          correlationID: "abcde12345",
          action: 1,
          mode: 1,
          exchangeType: 3,
          tokens: ["999901"],
        };
        web_socket.fetchData(json_req);
        web_socket.on("tick", receiveTick);
    
        function receiveTick(data) {
          console.log("receiveTick:::: :", data, data?.token);
    

    if (data?.token === '"999901"') {
    symbolResponse["SENSEX"]["Price"] = data?.last_traded_price;
    }
    process.send({
    type: "connectionConfirmation",
    data: data.subscription_mode === "1" ? "Success" : "Failed",
    symbolData: symbolResponse,
    });
    }
    })
    .catch((err) => {
    console.log("Custom error :", err.message);
    });
    }
    });


  • Hello @ajay1234
    As of now you are framing the request to the json_req1 key an d then you are passing json_req So kindly pass the updated key
    Regards,
    SmartAPI Team