All skills
Databases & Realtime
WebSockets
Overview
WebSocket is a computer communications protocol, providing a bidirectional communication channel over a single Transmission Control Protocol (TCP) connection. The protocol was standardized by the IETF as RFC 6455 in 2011. The current specification allowing web applications to use this protocol is known as WebSockets. It is a living standard maintained by the WHATWG and a successor to The WebSocket API from the W3C.
Read moreHow it works
js
const ws = new WebSocket("wss://example.com");
ws.onmessage = (e) => console.log(e.data);
ws.send("hello");The flow
Step by step, from source to running.
- 1Client sends an HTTP Upgrade
- 2Server switches protocols (101)
- 3Full-duplex channel stays open
- 4Both sides push frames anytime