Peer Connection

Establishing a direct connection between two devices typically requires a dedicated central server. Peer connection bypasses the server requirement by helping to connect two devices, making each device serve as a client and a server.

What is a Peer Connection?

Peer Connection is a WebRTC specification that uses peer-to-peer protocol to encode and decode media, transport information, and ensure effective communication between two participants of different networks. It helps establish a connection between two participants and ends it when no longer needed. In peer connection, the devices can exchange information (audio, video, data in different formats) about each other's network. The information sharing helps to establish effective communication between the devices.

How does Peer Connection Work?

Establishing a peer connection begins with signaling. Here, the devices of different networks need to share information about network addresses. One of the devices creates an offer and informs the other about its capabilities. Before the communication can occur,  connectivity information about the other device must also be shared. An external service called ICE is used to identify candidates to communicate. The ICE uses a STUN or TURN server. More information about peer connection can be found on the WebRTC website.

Benefits of Peer Connection

  • Since the communication is direct in a peer connection, there is a reduced latency and easy discoverability.
  • It is easy to manage since there are no central servers. 
  • It is cheaper to build because it does not require costly infrastructure. 
  • It can scale to accommodate a large number of participants.

Application Areas of Peer Connection

  • File sharing: It is usually used in file-sharing services and applications. 
  • Gaming: Online gaming services typically use peer connection to ensure real-time communication between gamers. 
  • WebRTC: For connecting peer A to peer B for real-time communication using a STUN or TURN server.

Frequently Asked Questions

How do devices in peer connection identify themselves?

Peer connection uses external signaling (ICE) to identify the devices on different networks.

Related Terms:

Next Steps

Start by opening an account and trying out our products. We’re here to help you understand the best solution to your use case. Contact us any time to learn more about Stream.

Chat Messaging

Build any kind of chat messaging experience without scalability or reliability issues.

Learn more about $ Chat Messaging

Activity Feeds

Build any kind of feed without the headache of scalability or reliability of your feeds.

Learn more about $ Activity Feeds