Sandro Paganotti
Sandro Paganotti

Reputation: 2313

Exchanging WebRTC RTCPeerConnection signals manually

I read that RTCPeerConnection doesn't care about the transport mechanism chosen to exchange signals (websocket, google channel, etc..). Do you think it would be possible to collect those signals, encode them with JSON and ask the user to send them to the other peer using an external mechanism (chat, email, ...) in order to completely bypass the need of a remote server?

I've done a little POC and this seems working only when both peers are on the same machine; any clue?

Thanks!

Upvotes: 4

Views: 5108

Answers (6)

Syl
Syl

Reputation: 1174

disclaimer: I work at Pusher.

Yes you can send it over any transport. However, websockets is a pretty good option these day since most of the browser support it.

As mention by @Vishnu, you can setup a socket.io server or if you don't want to go through the hassle of setting that up, you can use hosted solutions like Pubnub or Pusher. I wrote a webRTC signaling tutorial using Pusher and thus Webosckets (+fallbacks) if you are interest.

http://pusher.com/tutorials/webrtc_chat

Upvotes: 1

user2569445
user2569445

Reputation: 11

Yes. Some points of interest are setLocalDescription(), setRemoteDescription(), createOffer(), and createAnswer().

Here's a proof-of-concept: https://github.com/cjb/serverless-webrtc/

Live demo: http://cjb.github.io/serverless-webrtc/serverless-webrtc.html

Upvotes: 1

Aki
Aki

Reputation: 3839

Yes you can. SDP is just a bunch of text, so you can choose any medium you want. An important piece of the SDP are ICE candidates, which I recommend including as part of the SDP; so it can all be send as one big string over medium of your choice(ajax, websockets, etc...).

Note that first SDP that you get from calling createOffer is not going to contain ICE candidates. You have to wait until "onicecandidate" callback gets called at least once to have some ICE candidates. Then you call createOffer again on your peer connection, which will then have all information(ICE candidates plus rest of SDP).

Also note that onicecandidate will be called as many times as needed until all of the local ICE candidates are figured out, so you could wait all for all of them until then to generate a complete SDP offer to send to the other side.

Upvotes: 2

harry young
harry young

Reputation: 770

No - as I understand it, you can't simply email Session descriptions.

ICE establishes the best route between peers, and I think the amount of ICE candidates may differ according to both client's current network situation.

If ice candidates and session desc are received, and then the client moves physical location (joining a different wifi network, for example), it would render ice candidates useless - meaning that the clients cannot connect.

I'm not an expert, so could easily be wrong. That answer is just from the webrtc knowledge i have gained whilst setting up my own signalling system for 2 clients using webrtc...

Upvotes: 0

Vishnu
Vishnu

Reputation: 2110

Yes. As long as each client receives the other client's SDP (which includes the ICE Candidates), you should be able to establish a PeerConnection. WebRTC is decoupled from the Signalling mechanism the application developers adopt. But it is imperative that these signals are transmitted, so that each client knows which IP-Port combination it should be paying attention to.

Now requesting the users to manually exchange and process these signals might turn out to be a tedious task. I'd recommend setting up a simple Server using Socket.io that would let you relay the signals with ease. You can always use AJAX Polling too.

Upvotes: 7

nakib
nakib

Reputation: 4434

Yes you can send it over email or any other transport. I don't think the result for the user will be the best, but it's one way to do it.

I would explain to you that the user that receives the SDP offer, must enter it in the browser, get the SDP answer, and send it back to the user that started the request. But I assume that when you say it works locally, you are doing all that.

You must wait for the ICE candidates too, as you are sending the offer and answers one time only, in order to allow peers to connect.

Upvotes: 2

Related Questions