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, constantly being updated by a team of amazing people. And it’s said you can spin up a production grade WebRTC application in a matter of hours, not weeks.

Because WebRTC is such a new technology, solid WebRTC APIs are still few and far between these days. But EasyRTC is also among the best 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 the basics of hooking EasyRTC into XirSys’s STUN and TURN servers.

Don’t like EasyRTC? You can hook any WebRTC API into our platform.


If you haven’t already, we highly suggest that you first read our Quick start guide. This guide should give you a fundamental understanding of our platform, making hooking EasyRTC into the Xirsys platform a piece of cake.

The Demo

EasyRTC’s demos can be found here. We’ve modified their basic demo for this tutorial. By default, it is configured to connect to Google’s STUN server at stun.l.google.com:19302, which is intended for public use. It does not connect to any TURN servers out of the box. That’s where we come in.

Creating a listener for the getIceConfig event

Priologic has made it very easy to specify your own STUN and TURN servers. To hook EasyRTC into the Xirsys platform, all you have to do is create a listener for the getIceConfig event. This is EasyRTC’s way of having a custom ICE configuration delivered on a per connection basis. iceConfig is the array we use to store Xirsys STUN and TURN servers — instead of the default Google STUN server — and have sent back via a callback.

But you can’t just hook into any ICE server. You must first make a POST request to https://global.xirsys.net/_turn with your Xirsys credentials, and only then can you pass the returned STUN and TURN servers into iceConfig.

Let’s edit server.js to create the event listener getIceConfig, where we’ll also initiate the POST request:

easyrtc.on("getIceConfig", function(connectionObj, callback) {
    // This object will take in an array of XirSys STUN and TURN servers
    var iceConfig = [];
        url: 'https://global.xirsys.net/_turn',
        qs: {
            ident: "myUsername",
            secret: "mySecret",
            channel: "myChannel",
            secure: 1
    function (error, response, body) {
        if (!error && response.statusCode == 200) {
            // body.v.iceServers is where the array of ICE servers lives
            iceConfig = body.v.iceServers;  
            callback(null, iceConfig);

Please keep in mind that this POST request should only be implemented in a secure environment, such as a server-side application or a compiled client-side application. Failure to do this will result in unwanted users hijacking your TURN bandwidth and other security flaws. Since this POST request is in server.js, we seem to be following this rule.

Please notice the fact that we’re setting iceConfig to body.v.iceServers, which is where the array of XirSys ICE servers lives.

A successful call should yield similar results to the array of servers returned below:

        url: 'stun:turn1.xirsys.com'
        username: 'e7db750a-2fcc-40c6-8415-cab22743a68a',                                                                                                                                                               
        url: 'turn:turn1.xirsys.com:443?transport=udp',                                                                                                                                                                 
        credential: '287ae254-9380-4f81-af88-e1cc9ed27eb0'
        username: 'e7db750a-2fcc-40c6-8415-cab22743a68a',                                                                                                                                                               
        url: 'turn:turn1.xirsys.com:443?transport=tcp',                                                                                                                                                                 
        credential: '287ae254-9380-4f81-af88-e1cc9ed27eb0'


Let’s try it out. We used the Simple Audio and Video Chat demo. If your XirSys call was truly successful, the new getIceConfig event listener should have replaced the default Google STUN server with XirSys STUN and TURN servers. You can confirm this within your Xirsys dashboard by checking how many STUN connections you had before and after testing the updated demo. The dashboard updates instantly, so if your STUN connections increased, congratulations. Achievement unlocked! You’ve successfully hooked EasyRTC into the XirSys platform.

Tying up loose ends

Although this demo now hooks into XirSys’s STUN and TURN servers, it still uses Priologic’s public signaling server. In a later tutorial, we’ll cover how to instead hook into XirSys’s signaling server.

We hope you’ve left with a solid understanding of what it takes to bring these two wonderful platforms together. You can also fork this customized EasyRTC demo from our GitHub, although it may not be as up to date as the official EasyRTC repository. This tutorial covered all the fundamentals you need to develop and deploy an awesome EasyRTC application that hooks into our highly reliable servers.