본문으로 건너뛰기
cccskills
무료GitHub에 공개

sse-websocket-streaming-expert

Expert guide for Server-Sent Events (SSE), WebSockets, and Streaming Architectures. Covers real-time data push, Socket.IO, Hono WebSocket, and AI response streaming / Panduan ahli streaming real-time.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구Redis
설치 방법 보기

포함된 파일(1)

  • SKILL.md5.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

SSE, WebSocket & Streaming Expert

English | Bahasa Indonesia


<a name="english"></a>

English

Description

A focused guide for building real-time data push architectures. While realtime-collaboration-expert focuses on CRDTs (Yjs) for multi-player editing, this skill focuses on the transport layer: when to use Server-Sent Events (SSE) vs WebSockets vs HTTP Streaming, scaling pub/sub architectures, and streaming AI responses.

Trigger Conditions

  • When building live notification systems, live sports scores, or stock tickers.
  • When streaming LLM text generation responses chunk-by-chunk to the UI.
  • When the user asks about "WebSockets", "Socket.IO", or "SSE".
  • When implementing a chat application.

Core Architectural Guidelines

1. SSE vs WebSockets

Choose the right transport mechanism to save server resources.

  • Server-Sent Events (SSE): Unidirectional (Server to Client). Uses standard HTTP. Best for live feeds, AI streaming, notifications. Handles reconnections automatically.
  • WebSockets: Bidirectional. Best for chat apps, multiplayer games. Requires a persistent TCP connection and custom ping/pong keepalives.

2. Streaming AI Responses (HTTP Streaming)

For LLMs, use standard HTTP Streaming (often via the ai SDK in React/Next.js) instead of complex WebSockets.

// Next.js Route Handler Example
export async function POST(req: Request) {
  const { prompt } = await req.json();
  const stream = await myLLM.stream(prompt);
  
  return new Response(stream, {
    headers: { 'Content-Type': 'text/event-stream' },
  });
}

3. Scaling WebSockets (Pub/Sub)

A single Node.js process can handle thousands of WebSockets, but when you scale horizontally (multiple servers), clients on Server A cannot see messages from Server B.

  • Redis Adapter: Use a Pub/Sub mechanism (like Redis) so when a message is published, all server instances broadcast it to their respective connected clients.
  • Serverless WebSockets: In serverless environments (AWS API Gateway, Cloudflare Durable Objects), you do not hold the connection in your code. The infrastructure holds it, and calls your webhook when messages arrive.

4. Reconnection & Idempotency

  • Always assume connections will drop.
  • Clients must maintain a lastEventId or cursor. Upon reconnection, the client sends this cursor so the server can push any missed messages, preventing data loss.

Orchestration & Integration

  • Supplements js-backend-expert or go-programming-expert with real-time push capabilities.
  • Essential for gemini-agent-booster when building AI streaming chat interfaces.
  • Integrates with api-gateway-proxy-expert to ensure proxies do not buffer streaming responses.

<a name="bahasa-indonesia"></a>

Bahasa Indonesia

Deskripsi

Panduan terfokus untuk membangun arsitektur push data real-time. Skill ini berfokus pada lapisan transport: kapan harus menggunakan Server-Sent Events (SSE) vs WebSockets vs HTTP Streaming, penskalaan arsitektur pub/sub (Redis), dan streaming respons AI.

Kondisi Pemicu

  • Saat membangun sistem notifikasi live, pembaruan skor, atau ticker saham.
  • Saat melakukan streaming teks hasil generasi LLM bagian-demi-bagian (chunk-by-chunk) ke UI.
  • Saat mengimplementasikan aplikasi obrolan (chat).

Panduan Arsitektur Inti

1. SSE vs WebSockets

Pilih mekanisme transport yang tepat:

  • Server-Sent Events (SSE): Satu arah (Server ke Klien). Berjalan di atas HTTP biasa. Sangat ideal untuk feed berita, notifikasi, dan streaming AI. Mendukung rekoneksi otomatis secara native.
  • WebSockets: Dua arah. Ideal untuk aplikasi chat dan game. Membutuhkan penanganan koneksi persisten dan mekanisme ping/pong manual.

2. Streaming Respons AI

Gunakan HTTP Streaming biasa (biasanya menggunakan text/event-stream) untuk merender kata demi kata dari AI tanpa perlu memelihara koneksi WebSocket yang kompleks.

3. Penskalaan (Scaling) WebSockets

Saat aplikasi diskalakan ke beberapa server (horizontal scaling), pengguna yang terhubung ke Server A tidak akan menerima pesan dari pengguna di Server B. Anda WAJIB menggunakan Redis Pub/Sub (atau mekanisme message broker serupa) sebagai backplane agar semua server saling berkomunikasi.

4. Rekoneksi & Penanganan Kehilangan Data

  • Klien harus selalu mengirimkan kursor (misal: ID pesan terakhir yang diterima) saat melakukan rekoneksi.
  • Server menggunakan kursor tersebut untuk memutar ulang (replay) pesan yang terlewat selama klien terputus.

Integrasi Orkestrasi

  • Melengkapi js-backend-expert atau go-programming-expert dengan kemampuan push real-time.
  • Sangat penting bagi gemini-agent-booster saat membangun antarmuka chat AI.
  • Terintegrasi dengan api-gateway-proxy-expert (pastikan NGINX/proxy tidak melakukan buffering pada koneksi streaming).

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Expert guide for automated and manual Web Accessibility (a11y) testing — axe-core, Pa11y, Playwright a11y, screen reader testing, and WCAG 2.2 Level AA/AAA compliance / Panduan ahli pengujian aksesibilitas web.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

roedyrustam/vibes-plug772026년 10월 18일 업데이트

Expert guide for intelligent model cascading and routing — complexity-scored task routing from Flash/Haiku to Sonnet/Opus/Astra, dynamic escalation with quality gates, 40-60% token cost reduction while maintaining output quality / Panduan ahli untuk kaskade dan routing model cerdas — routing tugas berbasis skor kompleksitas dari Flash/Haiku ke Sonnet/Opus/Astra, eskalasi dinamis dengan gerbang kualitas, pengurangan biaya token 40-60% dengan kualitas output terjaga.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

roedyrustam/vibes-plug772026년 10월 18일 업데이트

Expert guide for Affective Computing, emotional AI, and real-time sentiment analysis through native multimodal tokens (voice intonation and facial micro-expressions) / Panduan ahli komputasi afektif, AI emosional, dan analisis sentimen real-time melalui token multimodal native.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

roedyrustam/vibes-plug772026년 10월 18일 업데이트

Expert guide for AI-assisted coding workflows — agentic code generation, multi-agent code swarms, self-healing CI/CD, automated PR review, spec-to-code pipelines, codebase knowledge graphs, and human-in-the-loop approval gates / Panduan ahli untuk workflow pengkodean berbasis AI — generasi kode agentic, code swarm multi-agen, CI/CD self-healing, review PR otomatis, pipeline spec-to-code, knowledge graph codebase, dan gate persetujuan human-in-the-loop.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

roedyrustam/vibes-plug772026년 10월 18일 업데이트

Expert guide for autonomous Machine-to-Machine (M2M) agent settlement, dual-rail fiat & stablecoin micro-clearing, dynamic budget envelopes, and cryptographic agent invoicing / Panduan ahli settlement otonom antar-agen (M2M), kliring mikro dual-rail fiat & stablecoin, pagu anggaran dinamis, dan penagihan agen kriptografis.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

roedyrustam/vibes-plug772026년 10월 18일 업데이트

Expert guide for long-term episodic memory integration (Mem0 v2, Letta/MemGPT, Zep v2), memory tier architecture, pgvector HNSW storage, and unified context management for autonomous AI agents / Panduan ahli untuk integrasi memori episodik jangka panjang (Mem0 v2, Letta/MemGPT, Zep v2), arsitektur tier memori, penyimpanan pgvector HNSW, dan manajemen konteks terpadu untuk agen AI otonom.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

roedyrustam/vibes-plug772026년 10월 18일 업데이트

roedyrustam의 스킬 모두 보기

이 스킬의 문제 신고