How does communication differ between WebSockets and Server-Sent Events (SSE)?
Directionality: WebSockets provide bidirectional (full-duplex) messaging, while SSE is a one-way stream from server to client over a long-lived HTTP response.
2 / 5
Which protocol does SSE run over?
SSE transport: uses ordinary HTTP with Content-Type: text/event-stream, so it works through most proxies and benefits from automatic reconnection built into the EventSource API.
3 / 5
What handshake initiates a WebSocket connection?
WebSocket upgrade: starts as an HTTP request with Upgrade: websocket; on a 101 Switching Protocols response the connection becomes a persistent WebSocket.
4 / 5
Which feature does SSE provide natively that raw WebSockets do not?
Auto-reconnect: EventSource automatically reconnects and can resume using the Last-Event-ID header. WebSockets require you to implement reconnection logic yourself.
5 / 5
When is SSE generally preferable to WebSockets?
Use SSE: for server push of text events (dashboards, notifications) where you do not need client-to-server streaming. WebSockets fit interactive, low-latency two-way scenarios.