WebSocket provides a bidirectional mechanism between web browsers and web servers for sending messages.

As opposed to HTTP, where only the client can send a request to the server; WebSocket enables each side in the connection to send messages without any need to wait for past responses.

WebSocket starts its life as a specialized HTTP request that validates if the server is capable of supporting WebSocket or not. If the response is positive, then the WebSocket “hijacks” the HTTP connection and turns it into a WebSocket connection.

Since WebSocket isn’t supported by all web servers and web proxies, it is sometimes used in parallel to other messaging mechanisms such as XHR and SSE.

WebSocket can also be used on top of TLS, creating a secured WebSocket connection.

Due to the nature of WebRTC, which requires both ends to be capable of receiving and sending messages at all times, many of the WebRTC services opt for the use of WebSocket as the transport of their signaling protocol.

About WebRTC Glossary

The WebRTC Glossary is an ongoing project where users can learn more about WebRTC related terms. It is maintained by Tsahi Levent-Levi of BlogGeek.me.

Looking to learn more about WebRTC? 

Check my WebRTC training courses