EasyRTC is a great WebRTC API built by our friends at Priologic. It is both powerful and secure, and the best part is that it’s open source and it’s said you can spin up a production grade WebRTC application in a matter of minutes, not weeks.

EasyRTC is among the best WebRTC SDK’s we’ve seen, so much so that we’ve decided to persuade our clients to use it and focus on our strength: highly reliable TURN servers.

This tutorial will teach you how to quickly hook into EasyRTC into Xirsys STUN and TURN servers.


We assume you have a basic understanding of what webrtc is and its potential, if not we recomend reading https://www.html5rocks.com/en/tutorials/webrtc/basics/

To start with EasyRTC, you must run through their quick install: https://github.com/priologic/easyrtc#installation-in-a-nutshell or you can use a more detailed install based on your system: https://github.com/priologic/easyrtc/blob/master/docs/easyrtc_server_install.md

If you have not done so already, please sign-up for a Xirsys account at https://xirsys.com/pricing/ and create a new channel. To learn how to create your first channel see section Channels and Sub-Channels at http://docs.xirsys.com/using-portal

Setting Up the ICE Call

Assuming you’ve installed EasyRTC correctly, the file we want to look at is in the root of your EasyRTC folder called "server.js". This is the js file that your Node server runs.

In reference to the EasyRTC documents here https://github.com/priologic/easyrtc/blob/master/docs/easyrtc_server_ice.md we are going to create a custom method called getIceConfig on the server.js file that will query the Xirsys API to get the ICE (STUN/TURN) list for the EasyRTC applications.

First log into your Xirsys account, navigate to the Services section using the left menu. If you’ve not done so, create your first channel.

This channel is a connection point for your applications so you can name it what you want. Once you created your channel, find the Quick Connect Example section below your channel info and select Node.js from the tabs listed. This will be the code we will use to authenticate with the Xirsys API and get your ICE credentials.

Return to your EasyRTC folder and open the server.js file in a text editor like Visual Studio Code or Sublime 3. At the bottom of the server.js file copy and paste the https and options object that is in your Quick Connect Example of your account. Do not copy the httpreq object just yet.

Now in reference to the EasyRTC documentation, we’re going to create a method for getIceConfig just below the code you entered.

easyrtc.on("getIceConfig", function(connectionObj, callback) {

Now you can copy and paste the httpreq object to the body of our getIceConfig method. But we are not done yet, we need to send our ICE list that is fed through the "end" method body of our httpreq object to the callback argument, which is sent from the getIceConfig function above. Here is the modification:

httpres.on("end", function(){ 
            var d = JSON.parse(str);
            if(d.s == 'ok'){
                var iceConfig = d.v.iceServers;
                console.log('server list: ',iceConfig);
                callback(null, iceConfig);

When the call ends, this method captures the ICE list as a JSON string, after parsing the string we check the status to make sure the call was successful and then we pass the array to the callback as the second argument.

Your code should look like this now:

Start the Server

Now you have what you need and you’re ready to run things. Open a terminal or DOS window and go to your EasyRTC directory.

Run the call to start your EasyRTC Node server:

node server

Open your browser to the URL specified for EasyRTC and click to go to demos. If running locally, it should be http://localhost:8080/demos/. All your applications should now connect to your Xirsys WebRTC account. Try the Simple Video+Audio demo and when connecting you should see the list of the ICE servers from your terminal or DOS window displayed.

If you later wanted to do the same for a different channel or if you updated your secret token, all you need to do is update the options object and re-run the server.


Now that you have the applications running and connecting, upload your EasyRTC node server to a node host and share your links to chat with colleagues and friends. If you have any questions or need help, please feel free to contact us at experts@xirsys.com.