title: WebRTC: One to one Audio call not working in different machine
body: <p>I am trying to implement a one to one audio call using webRTC (signalling using websockets) .  But it works when i try it in one system using multiple tabs of chrome (localhost). When I try to hit my server from another machine it does initial handshakes , but call doesn't happen.</p>
  
  <p>But when i try to change the  tag to  and changed the constraints to video constraints . it works even if the we try to access from  other machine (i.e video call works ).</p>
  
  <p>I initially thought it was because if firewall but when video call worked I was puzzled . </p>
  
  <p>Here is my code:</p>
  
  <pre><code>// Constraints to get audio stream only
  $scope.constraints = {
      audio: {
              mandatory: {
                  googEchoCancellation: true
              },
              optional: []
          },
      video:false
  };
  
  navigator.getUserMedia = navigator.getUserMedia ||
      navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
  
  // success Callback of getUserMedia(), stream variable is the audio stream.
  $scope.successCallback = function (stream) {
      if (window.URL) {
          myVideo.src = window.URL.createObjectURL(stream); // converting media stream to Blob URL.
      } else {
          myVideo.src = stream;
      }
      //attachMediaStream(audioTag, stream);
      localStream = stream;
      if (initiator)
          maybeStart();
      else
          doAnswer();
  };
  
  // failure Callback of getUserMedia()
  $scope.failureCallback = function (error) {
      console.log('navigator.getUserMedia Failed: ', error);
  };
  var initiator, started = false;
  
   $("#call").click(function () {
      socket.emit("message", undefined);
      initiator = true;
      navigator.getUserMedia($scope.constraints, $scope.successCallback, $scope.failureCallback);
  });
  
  var channelReady = false;
  socket.on('message', function (data) {
      channelReady = true;
      if (data) {
          if (data.type === 'offer') {
              if (!initiator) {
                  $("#acceptCall").show();
                    $("#acceptCall").click(function(){
                        if (!initiator &amp;&amp; !started) {
                      var pc_config = {
                          iceServers: [
                       { url: "stun:stun.l.google.com:19302" },
                        { url: "turn:numb.viagenie.ca", credential: "drfunk", username: "toadums@hotmail.com"}
                       ]
                      };
                      pc = new webkitRTCPeerConnection(pc_config);
                      pc.onicecandidate = onIceCandidate;
                      pc.onaddstream = onRemoteStreamAdded;
                  }
                  pc.setRemoteDescription(new RTCSessionDescription(data));
                        $scope.acceptCall();
                    });
  
              }
          } else if (data.type === 'answer' &amp;&amp; started) {
              pc.onaddstream = onRemoteStreamAdded;
              pc.setRemoteDescription(new RTCSessionDescription(data));
  
          } else if (data.type === 'candidate' &amp;&amp; started) {
              var candidate = new RTCIceCandidate({
                  sdpMLineIndex: data.label,
                  candidate: data.candidate
              });
              pc.addIceCandidate(candidate);
          } else if (data.type === 'bye' &amp;&amp; started) {
              console.log("Bye");
          }
      }
  });
  
   function onRemoteStreamAdded(event) {
      othersVideo.src = URL.createObjectURL(event.stream); 
   };
    var sdpConstraints = {
     'mandatory': {
       'OfferToReceiveAudio': true,
       'OfferToReceiveVideo': false
     }
   };
  function doAnswer() {
      pc.addStream(localStream);
      pc.createAnswer(gotDescription,null,sdpConstraints);
  }
  function gotDescription(desc) {
          pc.setLocalDescription(desc);
          socket.send(desc);
      }
  
  function maybeStart() {
      if (!started &amp;&amp; localStream &amp;&amp; channelReady)
          createPeerConnection();
          pc.addStream(localStream);
          started = true;
          if (initiator)
              doCall();
      }
  
  $scope.acceptCall = function () {
      navigator.getUserMedia($scope.constraints, $scope.successCallback, $scope.failureCallback);
  }
  
  function createPeerConnection() {
      var pc_config = {
           iceServers: [
           { url: "stun:stun.l.google.com:19302" },
           { url: "turn:numb.viagenie.ca", credential: "drfunk", username: "toadums@hotmail.com"}
           ]
      };
  
      pc = new webkitRTCPeerConnection(pc_config);
      pc.onicecandidate = onIceCandidate;
      console.log("Created RTCPeerConnnection with config:\n" + "  \"" +
          JSON.stringify(pc_config) + "\".");
  };
  
  
  function doCall() {
      $scope.caller = true;
      pc.createOffer(setLocalAndSendMessage,null,sdpConstraints);
  };
  
  function setLocalAndSendMessage(sessionDescription) {
      pc.setLocalDescription(sessionDescription);
      socket.send(sessionDescription);
  }
  
  function onIceCandidate(event) {
      if (event.candidate) {
          socket.emit('message', {
              type: 'candidate',
              label: event.candidate.sdpMLineIndex,
              id: event.candidate.sdpMid,
              candidate: event.candidate.candidate
          });
      } else {
          console.log("End of candidates.");
      }
  }
  </code></pre>