React Api Reference
    Preparing search index...

    Function getNetworkStats

      • This method can be used to retrieve network statistics such as upload and download speed.
      • The method returns a Promise that resolves with network speed statistics or rejects if the operation fails or exceeds the specified timeout.
      • The result object will include the downloadSpeed and uploadSpeed, expressed in megabytes per second (MB/s).

      Parameters

      • Optionaloptions: { timeoutDuration?: number }
        • OptionaltimeoutDuration?: number

          It helps prevent the method from getting stuck indefinitely when fetching network statistics. It lets you set a maximum time for the operation, and if it takes longer than that, the method stops gracefully.

          You can specify timeoutDuration in milliseconds. If it is not provided or is not an integer, the default timeout is set to 60,000 milliseconds (1 minute).

      Returns Promise<{ downloadSpeed: number; uploadSpeed: number }>

      import { getNetworkStats } from "@videosdk.live/react-sdk";

      try {
      const options = { timeoutDuration: 45000 }; // Set a custom timeout of 45 seconds
      const networkStats = await getNetworkStats(options);
      console.log("Download Speed: ", networkStats["downloadSpeed"]); // will return value in Mb/s
      console.log("Upload Speed: ", networkStats["uploadSpeed"]); // will return value in Mb/s
      } catch(ex) {
      console.log("Error in networkStats: ", ex);
      }