WebSocketV2 fetchData function response


  • While fetching data using

    let json_req = {
    correlationID: "abcde12345",
    action: 1,
    mode: 3,
    exchangeType: data.exchanger === "NFO" ? 2 : 4,
    tokens: marketToken[data.index],
    };

    WebSocketV2response.fetchData(json_req);

    WebSocketV2response.on("tick", async (response) => {
    });

    when i provide 1 then i get data continuously but when i provide 0 then i receive pong as a data.

    I want to receive data once for single request or continuously after few seconds or minutes but while providing 1 it is giving me the same data continuously for what i have requested without any latency because of which i am unable to compute on present data , it's get changes so fast , computing on present data is not possible.

    How can i receive data with some latency so that i can computing on present value of data and again i request or by itself it sends data after few seconds or minutes it should fetch data using fetchData function ?

    THANK YOU


  • @Moderator_2
    Nothing is working neither

            setInterval(() => {
                WebSocketV2response.on("tick", async (response) => {
                    console.log(response);
                });
            }, 3000); 
    

    nor

            setTimeout(function () {
                WebSocketV2response.on("tick", async (response) => {
                    console.log(response);
                });
            }, 3000);
    

    It's receving data continuosly after 3 sec in both the cases ?


  • @Moderator_2 said in WebSocketV2 fetchData function response:

    Hi @greatworld

    Action param on Websocket request represents zero to unsubscribe(feed stops) and one to subscribe(feed starts) the scripts.
    For some scripts, we may not notice any changes on the ticks since there wont be any trade occurring for it. We provide feeds continuously that is received from exchange end.
    If it is required to fetch data with latency time delay can be added. Kindly refer below
    Ref:
    https://masteringjs.io/tutorials/node/sleep

    Regards,
    SmartAPI team

    THANK YOU TEAM FOR YOUR SUPPORT


  • Hi @greatworld

    Action param on Websocket request represents zero to unsubscribe(feed stops) and one to subscribe(feed starts) the scripts.
    For some scripts, we may not notice any changes on the ticks since there wont be any trade occurring for it. We provide feeds continuously that is received from exchange end.
    If it is required to fetch data with latency time delay can be added. Kindly refer below
    Ref:
    https://masteringjs.io/tutorials/node/sleep

    Regards,
    SmartAPI team