0
votes

In the following article: WebRTC Cookbook Article

is explained how a java signaling server can be implemented.

It is said that:

So both clients exchange the necessary data (including network details) and then establish direct peer-to-peer connection. After the connection is established, peers don't use the server anymore.

But looking at the code the server is still needed to relay the communication to all clients (sendToAll-method).

Can anyone explain me how a direct peer-to-peer communication is possible with such a code? I still can't figure out how 2 (or more) clients can communicate p2p.

2

2 Answers

0
votes

It means that when the p2p WebRTC connection is up and running, then the signaling server is really not used.

Although, the signaling server could provide some additional features - like broadcasting text chat (when one peer can send text data to all other peers). And in that case, your application can still utilize signaling server for exchanging extra data between peers, but it would be not the WebRTC data, it would be data that are meaningful for the application only and not for the WebRTC stack.

So, in a normal case WebRTC stack doesn't use the signaling after the p2p connection is established (but actually the signaling channel CAN BE used for re-negotiation, for example). But still your application is totally free to keep using the signaling channel for its own extra data. It actually totally depends on the logic you have implemented in the application and in the signaling server.

0
votes

The signaling server is used to establish a WebRTC peer connection. The peer connection is a direct connection between two pairs for audio, video, and data.

It is not generally possible to setup a WebRTC peer connection without a signaling server because most users do not have fixed IP addresses and are behind network address translation (NAT) systems and stateful firewalls. The signaling server relays messages between two users until they can successfully negotiate a peer connection using, for exanmple, STUN to discover their IP addresses as seen over the internet.

Once the peer connection is established, the signaling server is not needed. You can, however, design a system where data is still sent over the signaling channel if this better suits your needs.

The signaling portion of WebRTC is unspecified. The signaling server needs to provide some method for users to select who they want to communicate with.

WebRTC has a point-to-point design. To support more than 2 peers, either each pair of peers needs to setup a peer connection, or a system needs a media server to combine audio/video streams.