I am trying to understand the difference between WebRTC and WebSockets so that I can better understand which scenario calls for what. I am curious about the broad idea of two parties (mainly web based, but potentially one being a dedicated server application) talking to each other.
Assumption:
Questions:
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).
WebRTC 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.
Websockets are highly faster than WebRTC !
WebSockets enable two-way communication via a single TCP communication, whereas WebRTC enables real-time peer-to-peer communication in the browser and mobile applications.
There is one significant difference: WebSockets works via TCP, WebRTC works via UDP. In fact, WebRTC is SRTP protocol with some additional features like STUN, ICE, DTLS etc. and internal VoIP features such as Adaptive Jitter Buffer, AEC, AGC etc.
So, WebSockets is designed for reliable communication. It is a good choice if you want to send any data that must be sent reliably.
When you use WebRTC, the transmitted stream is unreliable. Some packets can get lost in the network. It is bad if you send critical data, for example for financial processing, the same issue is ideally suitable when you send audio or video stream where some frames can be lost without any noticeable quality issues.
If you want to send data channel via WebRTC, you should have some forward error correction algorithm to restore data if a data frame was lost in the network.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With