sansex data is not coming in websocket


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

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

    };
    var derivativesResponse = {};

    process.on("message", function (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_req = {
          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);
       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);
      });
    

    }
    });