title: Local WebRTC signaling server
body: <p>I am using firebase signaling server for my webRTC website.</p>
  
  <p>I am informed I can use websocket for implementation of my own local signaling server.</p>
  
  <p>I tried the example on <a href="https://github.com/muaz-khan/WebRTC-Experiment/tree/master/websocket-over-nodejs" rel="nofollow">Link</a> and it works. When I replace my firebase code it doesn't work.</p>
  
  <p>Firebase code </p>
  
  <pre><code>var config = {
              openSocket: function(config) {
  
                  var channel = config.channel || location.href.replace(/\/|:|#|%|\.|\[|\]/g, '');
                  var socket = new Firebase('https://webrtc.firebaseIO.com/' + channel); //EXTERNAL SERVER need change
                  socket.channel = channel;
                  socket.on("child_added", function(data) {
                      config.onmessage &amp;&amp; config.onmessage(data.val());
                  });
                  socket.send = function(data) {
                      this.push(data);
                  };
                  config.onopen &amp;&amp; setTimeout(config.onopen, 1);
                  socket.onDisconnect().remove();
                  return socket;
  
              },
  </code></pre>
  
  <p>Websocket over nodejs code</p>
  
  <pre><code>var channelName = location.href.replace(/\/|:|#|%|\.|\[|\]/g, ''); // using URL as room-name
  
              var SIGNALING_SERVER = 'ws://172.20.34.132:12034';
              connection.openSignalingChannel = function(config) {
                  config.channel = config.channel || this.channel;
                  var websocket = new WebSocket(SIGNALING_SERVER);
                  websocket.channel = config.channel;
                  websocket.onopen = function() {
                      websocket.push(JSON.stringify({
                          open: true,
                          channel: config.channel
                      }));
                      if (config.callback)
                          config.callback(websocket);
                  };
                  websocket.onmessage = function(event) {
                      config.onmessage(JSON.parse(event.data));
                  };
                  websocket.push = websocket.send;
                  websocket.send = function(data) {
                      websocket.push(JSON.stringify({
                          data: data,
                          channel: config.channel
                      }));
                  };
              }
  </code></pre>