JavaScript · Senior · Question 15 of 75
How do Server-Sent Events differ from WebSocket?
- ✓Correct answer: SSE is a one-way stream from the server over HTTP, WebSocket a two-way channel
- 2SSE is a two-way channel, while WebSocket only sends data from the server
- 3SSE works only in Node.js, WebSocket only in the browser
Explanation
SSE (EventSource) is simpler: plain HTTP, automatic reconnection, text events - enough for notifications and streaming responses. WebSocket is needed for frequent two-way exchange (chats, games, collaborative editing) and supports binary data.