COMPUTER ENGINEER

Jump to examples
Blog
HTTP / HTTPS / TLS6 min study
61/ 70

Live streams and webhooks

Polling, SSE and WebSockets

Choose a connection model for the required flow.

UnderstandStudy an examplePractise

Understand the concept

Polling requests periodically, trading simplicity for empty responses or delay. Long polling holds a request until an event or timeout. SSE streams server-to-client events through text/event-stream.

WebSockets support bidirectional messaging, not a universally better solution. After the handshake, framing differs from ordinary HTTP exchanges. Plan proxy timeouts, heartbeats, reconnect and backpressure.

SSE IDs can support resuming with a defined replay store. EventSource credentials/header capabilities differ from Fetch. Authenticate, authorise and limit long-lived connections, with bounded reconnection behaviour.

WHEN TO USE IT

Build notifications, job progress and live status.

COMMON PITFALL

Assuming WebSockets automatically solve reconnect and ordering.

01 / PRACTICE

One topic. Three levels of depth.

HTTP / illustrative example
Polling: GET /jobs/123 every bounded interval

Choose a bounded interval deliberately.

This page does not send requests to external servers. Messages are readable HTTP/1.1 illustrations, not HTTP/2 or HTTP/3 wire dumps. example.test is reserved for examples. Run commands and JavaScript only in your own test environment; never publish real tokens or cookies.

02 / YOUR TURN

Try it yourself first.

Is WebSocket necessary for one-way job progress?

Show the solution and explanation
Worked solution
One-way events → consider SSE

No; SSE may suit the flow, depending on infrastructure.