npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webrtc-connection-tester

v1.0.0

Published

This is an NPM package to test your webrtc connection before joining call or meetings

Downloads

4

Readme

🧰 Installation

Using npm or yarn 📦

# Using npm
npm install webrtc-connection-tester

# Using yarn
yarn add webrtc-connection-tester

📄 Documentation

📗 Index

useConnectivityTest

This React custom hook facilitates testing WebRTC connectivity.

Usage

import React from 'react';
import {useConnectivityTest} from 'webrtc-connection-tester';

const MyComponent = () => {
  const { message } = useConnectivityTest('srflx', [
    {
      credential: "your turn server password",
      urls: ['your turn servers urls'],
      username: "your turn servers username",
    },
  ],);

  return (
    <div>
      {message.map((msg, index) => (
        <p key={index}>{msg}</p>
      ))}
    </div>
  );
};

Props

  • type: ('relay' | 'srflx' | 'host') Defines the preferred ICE candidate type.
  • iceServers: (RTCIceServer[]) An array of ICE servers for connectivity.

Return Value

  • message: (string[]) An array of messages logging test progress and results.

Example Output

Gathered candidate of Type: host Protocol: udp Address: 192.168.1.100
Gathered candidate of Type: host Protocol: udp Address: 2402:8100:24aa:d2f4:bb3:49bc:3797:c28a
Data successfully transmitted between peers.
Test done:

useDataChannelThroughputTest

This React custom hook measures WebRTC data channel throughput.

Usage

import React from 'react';
import {useDataChannelThroughputTest} from 'webrtc-connection-tester';

const MyComponent = () => {
  const { message } = useDataChannelThroughputTest([
    {
      credential: "your turn server password",
      urls: ['your turn servers urls'],
      username: "your turn servers username",
    },
  ]);

  return (
    <div>
      {message.map((msg, index) => (
        <p key={index}>{msg}</p>
      ))}
    </div>
  );
};

Props

  • iceServers : (RTCIceServer[]) An array of ICE servers for connectivity.

Return Value

  • message: (string[]) An array of messages logging test progress and results.

Example Output

Transmitting at 1234 kbps.
...
Total transmitted: 5678 kilo-bits in 1.23 seconds.
Test done.

useNetworkTest

This React custom hook gathers WebRTC ICE candidates based on a specified protocol.

Usage

import React from 'react';
import {useNetworkTest} from 'webrtc-connection-tester';

const MyComponent = () => {
  const { message } = useNetworkTest('tcp', [
    {
      credential: "your turn server password",
      urls: ['your turn servers urls'],
      username: "your turn servers username",
    },
  ]);

  return (
    <div>
      {message.map((msg, index) => (
        <p key={index}>{msg}</p>
      ))}
    </div>
  );
};

Props

  • protocol: ('tcp' | 'udp') The protocol to filter ICE candidates for.
  • iceServers: (RTCIceServer[]) An array of ICE servers for connectivity.

Return Value

  • message: (string[]) An array of messages logging test progress and results.

Example Output

Gathered candidate of Type: host Protocol: tcp Address: 192.168.1.100
Test done.

useVideoBandwidth

This React custom hook measures video bandwidth using WebRTC.

Usage

import React from 'react';
import {useVideoBandwidth} from 'webrtc-connection-tester';

const MyComponent = () => {
  const gatheredStatsReport = useVideoBandwidth([
    {
      credential: "your turn server password",
      urls: ['your turn servers urls'],
      username: "your turn servers username",
    },
  ]);

  // Access and display the gatheredStatsReport data here
  // ...

  return (
    <div>
      {gatheredStatsReport ? (
        <ul>
          <li>Round Trip Time: {gatheredStatsReport.RoundTripTime} sec</li>
          <li>
            Bandwidth Estimate Average:{" "}
            {gatheredStatsReport.bandwidth_estimate_average} kbps
          </li>
          <li>
            Bandwidth Estimate Max: {gatheredStatsReport.bandwidth_estimate_max}{" "}
            kbps
          </li>
          <li>Packets Sent: {gatheredStatsReport.packetsSent}</li>
          <li>Packets Received: {gatheredStatsReport.packetsReceived}</li>
          <li>NACK Count: {gatheredStatsReport.nackCount}</li>
          <li>PLI Count: {gatheredStatsReport.pliCount}</li>
          <li>QP Sum: {gatheredStatsReport.qpSum}</li>
          <li>Frames Encoded: {gatheredStatsReport.framesEncoded}</li>
          <li>Frames Decoded: {gatheredStatsReport.framesDecoded}</li>
        </ul>
      ) : null}
    </div>
  );
};

Props

  • iceServers: (RTCIceServer[]) An array of ICE servers for connectivity.

Return Value

  • reportType | null: An object containing video bandwidth statistics if successful, otherwise null.

Example Output

  Round Trip Time: 0.123 sec
  Bandwidth Estimate Average: 1234 kbps
  Bandwidth Estimate Max: 5678 kbps
  Packets Sent: 1024
  Packets Received: 987
  NACK Count: 5
  PLI Count: 2
  QP Sum: 12345
  Frames Encoded: 100
  Frames Decoded: 99

✍🏻 Creator

prashil vaishnani