---
concept: SSE vs WebSocket
slug: sse-vs-websocket
verified: true
verification_date: 2026-06-27
sources:
  - url: https://codelit.io/blog/sse-server-sent-events-guide
    title: Server-Sent Events: The Complete Guide
    language: en
    date: 2026-03-29
    excerpt: "SSE is server-to-client communication only and based on HTTP. WebSocket enables two-way, full-duplex communication."
  - url: https://juejin.cn/post/7504167136328269858
    title: 全面解析 Server-Sent Events（SSE）协议
    language: zh
    date: 2025-05-15
    excerpt: "大模型流式输出首选 SSE；双向高频交互使用 WebSocket"
related:
  - sse-protocol
tags:
  - comparison
  - architecture
---

# SSE vs WebSocket

## When to Use SSE
- Server pushes data to client (notifications, live feeds, progress updates)
- Simple implementation needed
- HTTP infrastructure compatibility matters (proxies, firewalls)
- LLM streaming output (ChatGPT-style)

## When to Use WebSocket
- Bidirectional communication needed (chat, gaming, collaboration)
- Binary data transfer
- High-frequency bidirectional messaging

## Comparison
| Feature | SSE | WebSocket |
|---------|-----|-----------|
| Direction | Server → Client | Bidirectional |
| Protocol | HTTP | ws:// (upgraded from HTTP) |
| Auto-reconnect | Built-in | Manual implementation |
| Binary data | No (text only) | Yes |
| Proxy friendly | Yes (plain HTTP) | May need configuration |
| Complexity | Low | Medium-High |

## Application in Blog Project
The pixel-art feature uses SSE because the server streams LLM painting steps to the client — a pure server-to-client data flow. No bidirectional communication is needed.
