2

Signaling is not addressed by WebRTC (even if we do have JSEP as a starting point), but from what I understand, it works that way :

  1. client tells the server it's available at X
  2. server holds that information and maps it to an identifier
  3. other client comes and sends an identifier to get connection information from the first client
  4. other client uses it to create it's one connection information and sends it to the server
  5. server sends this to first client
  6. both client can now talk

This is all nice and well, but what happends if a 3rd client arrives ?

You have to redo the whole things. Which suppose the first two clients are STILL connected to the server, waiting for a 3rd client to signal itself, and start the exchanging process again so they can get the 3rd client connection information.

So does it mean you are required to have to sort of permanent link to the server for each client (long polling, websocket, etc) ? If yes, is there a way to do that efficiently ?

Cause I don't see the point of having webRTC if I have to setup nodejs or tornado and make it scales to the number of my users. It doesn't sound very p2pish to me.

Please tell me I missed something.

Community
  • 1
  • 1
Bite code
  • 578,959
  • 113
  • 301
  • 329

1 Answers1

2

What about a chat system? Do you really need to keep a permanent link to the server for each client? Of course, because otherwise you have no way of keeping track of a user's status. This "permanent" link can be done different ways: you mentioned WebSocket and long polling, but simple periodic XHR polling works too (although this will affect the UX, depending on the interval).

So view it like a chat system, except that the media stream is P2P for reduced latency. Once a P2P WebRTC connection is established, the server may die and, of course, the P2P connection will be kept between the two clients. What I mean is: both users may always block your server once the P2P connection is established and still be connected together in the wild Internets.

Understand me well: once the P2P connection is established, your server will not be doing any more WebRTC signalling. The connection is only needed to keep track of the statuses.

So it depends on your application. If you want to keep the statuses of users and make them visible to others, then you're in the same situation as a chat system: you need to keep a certain link, somehow, to make sure their statuses are synced. Otherwise, your server exists to connect them together and is not needed afterwards. An example of the latter situation is: a user goes to a webpage, the webpage provides him with a new room URL, the user shares this URL to another peer by another mean, the other peer joins the room, server connects them together (manages WebRTC signalling) and then forgets them. They are now connected until one of them breaks the link. Just like this reference app.

Instead of a central server keeping one connection per client, a mesh network could also be considered, albeit difficult to implement.

eepp
  • 7,255
  • 1
  • 38
  • 56
  • I +1 but the whole purpose of webrtc isn't it to avoid using a server from the begining ? Now you need a STUN server, sometime a TURN server, and a signaling server that all client stays connected to all the time to say if there are in or out. Granted, we do save hosting bw from not having the messages beetween peers going thougth the serveur, but that's still A LOT to maintain. – Bite code Jun 22 '13 at 06:46
  • 1
    Of course it is. It's not a "simple" technology. But still: it's nice that now and in the future, two peers have a mean to connect together using a server for initial signalling. `RTCDataChannel` is promising too: once the connection is established, transfer _anything_ P2P, not just media streams. BTW, STUN and TURN are used by ICE (if you configure the connection with such servers) to traverse NATs: they are not required if you are absolutely certain the users don't have to traverse NATs (but it's almost always the case). – eepp Jun 22 '13 at 07:42