Skip to content

PeerRTC/PeerRTC-Twilio-IceServers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PeerRTC Twilio IceServers ☃️

A simple backend server used by PeerRTC for retrieving default ice servers provided by Twilio. Using this server is optional since there are a lot of ways to obtain ice servers.

💡 Additional Info

  • If no configurations parameter are provided in the PeerRTC constructor, then the module will automatically fetch ice servers from the server owned by us.

  • It is adviseable to provide own way of obtaining ice servers since we are only using free account in Twilio.

⚙️ Setup

  1. Create account and log in Twilio.
  2. Install Node.js first. Skip this step if already installed.
  3. Clone this repository.
  4. In command line, navigate to root directory of the newly downloaded repository.
  5. Install all needed dependencies via npm install in the command line.
  6. Set the enviroment variables. The server needed the TOKEN and SID environment as it will be passed in the Twilio api. In the command line,
set SID=your-account-sid
set TOKEN=your-token

Account sid and token can be found in Twilio console on Account Info section.

  1. Start the server by entering npm start in the command line.

👨‍🏫 Usage

The server is using the getIceServers get method to return an array of ice servers.

https://your-server.com/getIceServers

The returned array can be inserted in the PeerRTC constructor as follows:

fetch("https://your-server.com/getIceServers")
  .then(response=>response.json())
  .then(iceServers=>{
  
    serverURL = "https://my-own-server-url.com"
    configurations = {
      iceServers: iceServers,
      ...
    }
    
   peer = new PeerRTC(serverURL, configurations)
  })