Creating a new RTCPeerConnection with Google stun servers doesn't work JS

82 views Asked by At

hey i want to make an app where users could stream audio to each other so i implemented firebase and firestore config (implemented firebase via CDN beacuse i have problem with it ) and i wanted to create RTCPeerConection but something is wrong with const servers. I get an error: Uncaught (in promise) Error: Cannot read properties of null (reading 'endsWith') at wrappedSendMessageCallback. Please help! Here's the code:

import { initializeApp } from "https://www.gstatic.com/firebasejs/9.4.0/firebase-app.js";
  import { getFirestore, doc, getDoc, getDocs, collection } from "https://www.gstatic.com/firebasejs/9.4.0/firebase-firestore.js";

const firebaseConfig = {
    apiKey: "my info",
    authDomain: "my info",
    projectId: "my info",
    storageBucket: "my info",
    messagingSenderId: "my info",
    appId: "my info"
  };

  // server config
const servers = {
    iceServers: [
      {
        urls: ['stun:stun1.l.google.com:19302', 'stun:stun2.l.google.com:19302'], // servers from google 
      },
    ],
    iceCandidatePoolSize: 10,
};

// global states
const pc = new RTCPeerConnection(servers);
let localStream = null; 
let remoteStream = null
0

There are 0 answers