19 comments on “Build your own phone company with WebRTC and a weekend

  1. Hello Chad – I am not even close to your expertize in coding. Forgot coding many years ago 🙂 However read your block and understood you are using your own Web/Signalling Server using socket.io. What about NAT servers? Are you using public ones or have your own or that provided by others/EASYRTC?

    • EasyRTC uses socket.io, so that is where that reference is from. I also used easyRTC’s default STUN servers:
      option.appIceServers = [ // Array of STUN and TURN servers. By default there is only publicly available STUN servers.
      {url: "stun:stun.l.google.com:19302"},
      {url: "stun:stun.sipgate.net"},
      {url: "stun:"},
      {url: "stun:stun.sipgate.net:10000"},
      {url: "stun:"}

      Adding a TURN server into the mix is something I would like to do in a future project.

  2. Nice post Chad. An easy way to provide some basic security is with iptables, Linux built in firewall. For now, you could just use a whitelist of good IP addresses.

    • Thanks Jim. I could definitely do that for the machines I know I will be using and my work domain. The challenge is almost device I use has a dynamic IP. I have been inviting others outside of my immediate family to the site so getting their IP addresses is difficult. If you have ideas on how to address that then please share!

  3. Nice, very nice indeed.
    I like the idea, especially in this time of NSA (et. al.) snooping on all our communications.
    How about some strong encryption?

    • The peer-to-peer media sessions are using WebRTC’s mandated DTLS encryption, but I agree I should absolutely encrypt the signaling communications. I need to look into how to force Secure Web Sockets on socket.io (used by EasyRTC) and I should use a secure mechanism to pass my login password to the server or use HTTPS.

      • I just implemented https with my EasyRTC server. It was very easy and straight forward. Dont forget about the SSL Certs….


        // Load required modules
        var https = require(“https”); // https server core module
        var fs = require(“fs”); // file system core module
        var express = require(“express”); // web framework external module
        var io = require(“socket.io”); // web socket external module
        var easyrtc = require(“easyrtc”); // EasyRTC external module

        // Setup and configure Express http server. Expect a subfolder called “static” to be the web root.
        var httpApp = express();
        httpApp.configure(function() {
        httpApp.use(express.static(__dirname + “/static/”));

        // Start Express https server on port 443
        var webServer = https.createServer(
        key: fs.readFileSync(“/pathtokeys/domain.key”),
        cert: fs.readFileSync(“/pathtokeys/domain.crt”)

        // Start Socket.io so it attaches itself to Express server
        var socketServer = io.listen(webServer, {“log level”:1});

        // Start EasyRTC server
        var rtc = easyrtc.listen(httpApp, socketServer);

  4. Chad,
    Thank you for taking time to share your knowledge and code with the community. I downloaded your source code and am able to get the code to run. I can login and logout, however, when I attempt to login again I get the following error messages:
    Authentication failed. Socket will be disconnected.Lost connection to signaling server.
    Do you have any idea how to resolve these issues?

    • I have not looked at this code in a while (I have an update on this on my to do list). It sounds like you may be having problems when calling “easyrtcServer = easyrtc.listen(app, socketServer);” for the second time. I would run the client in a debugger to verify where this is happening and check to see what it says on the server side. I would also recommend going to EasyRTC’s message board to see if they have anything to say about it – something may have changed on their end in the last 14 months since I wrote this.

  5. Hi Chad, its really Well organized and i will try to implement this.

    But i was wondering will WebRTC work with http/2 to improve the speed and the audio/Video Quality? because i never seen anyone use this with newly released protocols like SPDY and HTTP/2 .


  6. Good demo. To run with android devices https is required, I added the first 2 and changed the last lines:

    var https = require(“https”); // https server core module
    var fs = require(“fs”); // file system core module


    var webServer = https.createServer(
    key: fs.readFileSync(“/@nico/@c/easyrtcserver/server.key”),
    cert: fs.readFileSync(“/@nico/@c/easyrtcserver/server.crt”)

    //var webServer = app.listen(process.env.port || 8080); //original WebMatrix port
    //var webServer = app.listen(8080);
    console.log(‘Listening on port ‘ + 8443);

    // Start Socket.io so it attaches itself to Express server
    var socketServer = io.listen(webServer);

  7. Hi Chad,

    First of all, great article!

    Second: I just git clone your project into a EC2 virtual machine, and I was able just to see my own camera, in both sides.

    Am I missing something?

    I used Bitnami Node.js ready machine, and redirected port 80 to 8080.


    Sandro Wiggers

  8. Thank you for the decent explanation but sorry for this newbie’s question, how do I build the project after I download the zip from git?
    Thank you very much, Sir.

  9. Greetings,

    I have been playing around with this script (great post and work BTW) and I have it seemingly working fine when using Chrome browser…however when I use FireFox I get the following message “Requested video size of 640×480 but got size of 0x0″…?

    Has anybody experienced this…? Workaround? Thank you in advance. Regards.

  10. Hi,

    Beautiful explanation and I could build a one to one call in no time. Needed to know how many clients can connect in one time in a session using easyrtc

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.