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.
-
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.
- Create account and log in Twilio.
- Install Node.js first. Skip this step if already installed.
- Clone this repository.
- In command line, navigate to root directory of the newly downloaded repository.
- Install all needed dependencies via
npm install
in the command line. - 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.
- Start the server by entering
npm start
in the command line.
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)
})