Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebRTC and Websockets. Is there a difference

I'm assuming that WebRTC is an API that decodes/encodes audio and video, although the communication between the server and the clients is done via web sockets, or some other network protocol? I'm a bit confused. Does WebRTC have its own communications protocol?

like image 288
AndrewMcLagan Avatar asked Oct 05 '12 03:10

AndrewMcLagan


People also ask

What is the difference between WebSocket and WebRTC?

What is the difference between WebRTC and WebSockets? While both are part of the HTML5 specification, WebSockets are meant to enable bidirectional communication between a browser and a web server and WebRTC is meant to offer real time communication between browsers (predominantly voice and video communications).

Is WebRTC better than WebSockets?

WebRTC vs WebSockets – Key DifferencesWebRTC is more secure; At the moment, WebRTC is only supported by certain browsers while WebSockets is compatible with almost all existing browsers; In terms of scalability, WebSockets uses a server per session approach and WebRTC is peer-to-peer.

Is WebRTC faster than WebSocket?

Websockets are highly faster than WebRTC !

What is better than WebSockets?

WebSocket approach is ideal for real-time scalable application, whereas REST is better suited for the scenario with lots of getting request. WebSocket is a stateful protocol, whereas REST is based on stateless protocol, i.e. the client does not need to know about the server and the same hold true for the server.


2 Answers

There's two sides to WebRTC.

  1. JavaScript APIs (getUserMedia) that allow an app to access camera and microphone hardware. You can use this access to simply display the stream locally (perhaps applying effects), or send the stream over the network. You could send the data to your server, or you could use...
  2. PeerConnection, an API that allows browsers to establish direct peer-to-peer socket connections. You can establish a connection directly to someone else's browser and exchange data directly. This is very useful for high-bandwidth data like video, where you don't want your server to have to deal with relaying large amounts of data.

Take a look at the demos to see both parts of WebRTC in action.

So in a nutshell:

  • WebSockets allow full-duplex communication between a browser and a web server.
  • WebRTC's PeerConnection allows full-duplex communication between two browsers.
like image 89
josh3736 Avatar answered Sep 20 '22 16:09

josh3736


WebRTC uses RTP (a UDP based protocol) for the media transport, but requires an out-of-band signaling channel to setup the communication. One option for the signaling channel is WebSocket.

like image 20
oberstet Avatar answered Sep 24 '22 16:09

oberstet