Search code examples
webrtcsignaling

PeerConnection: make a call in local network


I'm playing around with WebRTC, and what I'd like to achive is:

User1 opens the browser at 192.168.x.x

User2 opens the browser at 192.168.x.x The same page

User 1 clicks call, user2 displays the stream on his screen.

I've created a signaling server with node and socket.io and I'm able to exchange messages betweeen users using socket.io rooms.

The steps I'm following are:

  • Get User Media
  • Create peerconnection1 - no ice servers
  • add the stream on peerconnection
  • create the offer
  • send offer via sockets
  • Receive the offer and create peerconnection2 - no ice servers
  • sending the answer

I've also put some logging in "onicecandidate" and "onaddstream" to see when they are called, and on "onaddstream" I create the videoelement.

When I press the call button I see on the other computer that the video element becomes black but I dont see any video neither audio. For sure I'm missing some vital steps,

Could someone tell me the steps I have to do to make a correct call and exchange all the necessary data to display the stream on the other side?

Thank you very much


Solution

  • A STUN server is used to get an external network address.
    TURN servers are used to relay traffic if direct (peer to peer) connection fails. 
    

    see this image describes how peerconnection works

    webRTC Basics

    enter image description here