Venkatesh
Venkatesh

Reputation: 587

webRTC to setup signaling server

how to setup a signaling server for webRTC when the system are connected in Local Area Network? Its mandatory that we must use STUN and TURN server for signaling?

Upvotes: 15

Views: 16965

Answers (3)

Arjun
Arjun

Reputation: 1

Making signalling server for WebRTC is quite easy. I used PHP, MYSQL and AJAX to maintain signalling data. Suppose A wants to call B.

Then A creates offer using createOffer method. This method returns an offer object. You have to transfer this offer object to user B, This is a part of signalling process.

Now create MYSQL database, having columns : caller, callee, offer, answer, callerICE and calleeICE

Now offer created by A is stored in offer attribute with the help of AJAX call .

(Remember to use JSON.stringify the JS object before "POSTing" object to server.)

Now user B scans this offer attribute created by caller A , again with the help of AJAX call.

In this way , offer object created at user A can arrive at user B.

Now, user B responds to the offer by calling createAnswer method. This method returns answer object. This can again be stored in "answer" attribute of database. Then the caller A scans this "answer" attribute created by callee B. In this way, answer object created by B can arrive at A.

To store iceCandidate object representing caller A, use "callerIce" attribute of MYSQL table. Note that, callee B is scanning "callerIce" to know the details of caller A. In this way we can transfer the iceCandidate objects representing future peer.

After you complete transferring of iceCandidate object, the connectionState property holds "connected" indicating two peers are connected.

If any questions, let me know!

Cheers ! You can now share local media stream to the remote peer.

Upvotes: 0

Deep Pai
Deep Pai

Reputation: 386

To make WebRTC run on LAN, you will require to have a signaling server in that LAN. A signaling server is any web server that will allow your web clients to exchange the SDP offer/answer and ICE candidates that are generated by the WebRTC PeerConnection. This can be done using AJAX or WebSockets.

I have listed some top sources for information about WebRTC. Please go through some of the links on that page to better understand how the WebRTC signaling works.

You will not require a STUN/TURN server as your WebRTC clients (i.e. Web Browser) will be in the LAN and accessible to each other. FYI... STUN/TURN servers are not part of the signaling but part of the media leg and usually required for NAT traversals of media.

Upvotes: 14

Ichigo Kurosaki
Ichigo Kurosaki

Reputation: 3843

Webrtc needs some kind of signalling system for initial negotiation.. like transferring SDP, ICE-candidates, sending and receiving offers etc... rest is done by peer-peer connection. For initial signalling you can use any technique like sending AJAX calls, using socket.io etc.

STUN and TURN servers are required for NAT traversal, NAT traversal is important because it is needed for determining the path between peers. You can use google provided STUN/TURN server address stun:stun.l.google.com:19302 etc , or you can configure your own turn server by using rfc-5766 turn server

Upvotes: 9

Related Questions