About

What Is SSE? A Simpler One-Way Stream Than WebSocket

Server-Sent Events: text/event-stream and auto-reconnect

SSE is an HTTP-based unidirectional streaming technology. The server can continuously send events to the client, but client-to-server communication requires separate HTTP requests. It is simpler than WebSocket, compatible with HTTP/2, and has automatic reconnection built into browsers.

Architecture Diagram

🌐
Client
EventSource API
① GET Request →
HTTP Keep-Alive
← ② text/event-stream
← data: {...}
← data: {...}
Unidirectional stream (Server → Client)
🖥️
Server
Content-Type: text/event-stream
On disconnect, the browser auto-reconnects (Last-Event-ID sent)
Flow Description
  1. Client sends HTTP GET request to server via EventSource API
  2. Server responds with text/event-stream, keeps connection
  3. Server streams events in data: format
  4. Browser auto-reconnects on disconnect

How It Works

1

Client sends HTTP GET request to server via EventSource API

2

Server responds with Content-Type: text/event-stream, maintaining connection

3

Server streams in data: format when events occur

4

Browser auto-reconnects on disconnect (using Last-Event-ID)

Pros

  • ✓ Simple implementation based on HTTP
  • ✓ Built-in automatic reconnection
  • ✓ Leverages HTTP/2 multiplexing
  • ✓ Text-based, easy to debug

Cons

  • ✗ Unidirectional only (server→client)
  • ✗ Inefficient for binary data transfer
  • ✗ Not supported in IE/older browsers
  • ✗ Max concurrent connection limit (6 in HTTP/1.1)

Use Cases

Real-time notifications/feeds AI chatbot streaming responses (ChatGPT) Stock price updates Build/deploy log streaming Live scoreboards
← What Is WebSocket? Two-Way Messaging Between Browser and Server What Is a GraphQL Subscription? Real-Time Data Shaped by Your Schema →