
SSE vs WebSocket in Practice — Two Real Endpoints, One Spring Boot Server
You've probably read the theory: SSE is unidirectional, WebSocket is bidirectional, use SSE when the server pushes data and WebSocket when the client talks back. But what does that actually look like in code? I built a small demo server ( livetimeserver ) that exposes both — an SSE endpoint and a WebSocket endpoint — side by side, both streaming the current time. A Next.js client ( livetimeclient ) connects to either one. This post walks through what's interesting about each. Repos Server: https://github.com/ravin-singh/livetimeserver (Spring Boot 4 + WebFlux, Java 25) Client: https://github.com/ravin-singh/livetimeclient (Next.js) The quick comparison SSE WebSocket Direction Server → client only Full duplex Protocol Plain HTTP Upgraded TCP ( ws:// ) Browser reconnect Built-in, automatic Manual Overhead Low (HTTP headers once) Very low (framed) Good for Feeds, live dashboards, logs Chat, collaborative editing, games SSE endpoint — /sse/v1/time @GetMapping ( "/time" ) public Flux < Serv
Continue reading on Dev.to Webdev
Opens in a new tab



