15 min read
SSE vs WebSockets: real-time updates in Node.js
In one sentence: For a client to find out about a change without asking every few seconds, the server leaves the connection open and writes when there's something new. With Server-Sent Events, an HTTP response that doesn't end, only the server talks; with WebSockets, both sides do.
What you will learn
- Explain what asking over and over costs (polling and long polling).
- Send an order's changes with Server-Sent Events and read them with curl and with EventSource.
- Recognize a WebSocket's protocol switch (101) and write an echo.
- Choose between polling, Server-Sent Events, WebSockets and webhooks depending on who has to talk to whom.
Before you start, read: 07-webhooks.md
The problem
Section titled “The problem”A customer pays for her order from the shop’s app. The payment gateway notifies the shop with the webhook from lesson 7, and the order changes to paid on the server. But the phone still says “pending”: nobody has told it.
The usual way out is for the app to ask every 2 seconds: GET /v2/orders/25, and again, and again. That’s 30 requests per minute for each open screen: with a thousand customers watching their orders, 30,000 per minute, almost all of them to hear “nothing new.”
And a webhook won’t do: the phone is behind a router with NATNAT stands for Network Address Translation.What the router does on the way out to the internet: it replaces your device’s private IP address with its own public one, and notes the change so it can undo it in the replies.Go to definition (Phase 0), with no address to call. The app has to open the connection, and the server has to use it to send the news. Here you’ll see two ways of doing it.
The analogy
Section titled “The analogy”The analogy
You’ve ordered a coffee in a crowded café. You can walk up to the counter every minute and ask “Is mine ready?” Almost every time, they say no. You can stay at the counter until they hand it to you. Or they give you a pager, that gadget that buzzes when your order is ready, and you sit down.
The pager only goes one way. To talk to the counter (“Can I have it with oat milk?” “We’re out. Is soy OK?”) you’d need an open phone call. The pager is Server-Sent Events; the call, a WebSocket.
Where the analogy breaks down
- The pager buzzes once and you hand it back; through a Server-Sent Events response, many notifications arrive.
- Outside the café, the pager loses its signal; the browser, on the other hand, reconnects on its own.
- On a call, if you both talk at once you can’t understand each other; over a WebSocket, both sides send at the same time without stepping on each other.
How it really works
Section titled “How it really works”Asking every few seconds: polling and long polling
Section titled “Asking every few seconds: polling and long polling”Asking over and over is PollingAsking a server every so often whether something has changed, even though the answer is almost always no. It’s the opposite of being notified, the way a webhook does it.Go to definition, as in lesson 7. It works with any server, but it costs requests that bring nothing and delay: if you ask every 10 seconds, you find out, on average, 5 seconds late.
In long polling, the server holds on to the request until there’s a change, or until a limit, like 30 seconds, and the client asks again. There are fewer empty requests, but each notification still costs a full request, with its HeaderInformation a protocol puts in front of its data to do its job. In HTTP they are text lines of the form “Name: value”, such as Host or Content-Type; in TCP or IP they are numbers in fixed positions, such as ports or addresses.Go to definition.
SSE and WebSockets turn it around: the client opens a connection once, and the server writes through it when it has something.
Server-Sent Events: a response that doesn’t end
Section titled “Server-Sent Events: a response that doesn’t end”SSESSE stands for Server-Sent Events.A way for the server to notify the client as soon as something happens. The client makes a normal HTTP request and the server leaves the response open, writing an event into it, a few lines of text, every time there’s news. It only goes one way, from the server to the client.Go to definition (SSE) is normal HTTP with one difference: the response doesn’t end. The server sends the headers, writes an event and leaves the connection open; with each change, it writes another one. This is how this lesson’s API answers (you’ll do it in “Try it”):
HTTP/1.1 200 OKcache-control: no-cacheconnection: keep-alivecontent-type: text/event-streamtransfer-encoding: chunked
event: statusdata: {"id":25,"productId":2,"quantity":2,"status":"pending","createdAt":"2026-10-08T09:00:00.000Z"}
event: statusdata: {"id":25,"productId":2,"quantity":2,"status":"paid","createdAt":"2026-10-08T09:00:00.000Z"}Look at the headers:
content-type: text/event-stream: the body is a list of events that keeps arriving.cache-control: no-cache: no CacheA saved copy of an answer, so it doesn’t have to be fetched again. It saves time, at the cost of the copy possibly being stale until it expires.Go to definition may reuse it without asking the server first (lesson 7 of Phase 2).transfer-encoding: chunkedand nocontent-length: the server doesn’t know how long the body will be, and sends it in pieces, like a StreamData that arrives or is sent little by little, in chunks, instead of all at once, so a program can read it as it arrives. In a Node.js server, the body of a request is a stream.Go to definition.
This is how the webhook’s news reaches the app:
- Shop API → Phone app200, text/event-stream
event: status (pending) - Phone app · Shop APIthe response stays open
- Shop API → Payment gateway200
- Shop API → Phone appevent: status (paid)
The format: lines of text and a blank line
Section titled “The format: lines of text and a blank line”Each event is a few field: value lines, and a blank line closes it. The fields:
| Field | What it’s for |
|---|---|
data: |
The content of the event. It’s text: here, the order in JSON |
event: |
A name for the event. Without it, the event is called message |
id: |
An identifier. When reconnecting, the browser sends the last one in the Last-Event-ID header |
In the browser, events are read with EventSource, which reconnects on its own if the connection drops: Chrome tries every 3 seconds. The shop doesn’t use id:: each connection starts with the current status, and that’s enough.
Notifying each change with an EventEmitter
Section titled “Notifying each change with an EventEmitter”The events route has to find out about the changes made by two others: the payment webhook and the cancellation. It needs a notice board, and Node comes with one, the EventEmitter. In src/data.ts:
// It announces each time an order changes status. Whoever wants to know (each connection that// follows an order, in v2.ts) subscribes with .on('change', …) and unsubscribes with .off.export const orderChanges = new EventEmitter<{ change: [Order] }>();// No limit on listeners: each open connection is one, and there can be many.orderChanges.setMaxListeners(0);
// Always change the status through here, so that nobody misses the notification.export function changeStatus(order: Order, status: OrderStatus) { order.status = status; orderChanges.emit('change', order);}Word by word:
new EventEmitter<{ change: [Order] }>()creates the board. Between<and>, for TypeScript: there’s one notice,change, and it carries an order..emit('change', order)posts a notice: it calls all the FunctionA named piece of code that takes some data, does something with it and returns a result. It’s written once and used as many times as needed.Go to definition subscribed tochange, with that order..onsubscribes a function, and.offremoves it.setMaxListeners(0)removes the warning Node gives with more than 10 functions subscribed (MaxListenersExceededWarning), which usually gives away a forgotten.off. Here each open connection subscribes one.changeStatusis the only door for changing a status: it changes it and posts the notice. Insrc/v2.ts, the cancellation and the webhook no longer writeorder.status = …; they call it instead: a change made by hand would go unseen.
The route that follows an order
Section titled “The route that follows an order”Its definition in src/contract.ts, like the ones from lesson 5, introduces a new type of response, text/event-stream:
// Server-Sent Events: a response that doesn't end. The content type, text/event-stream.export const followOrder = createRoute({ method: 'get', path: '/orders/{id}/events', tags: ['Orders'], summary: "An order's status changes, live", request: { params: idSchema }, responses: { 200: { description: 'A "status" event with the current order and, after that, one for each change', content: { 'text/event-stream': { schema: z.string() } }, }, 404: withProblem('No such order'), 422: invalidData, },});And the route, in src/v2.ts:
// The response starts and doesn't end: each event is one more piece of the same response. First,// the current status; after that, each change. If the connection drops, EventSource reconnects on// its own and gets the current status again: nothing is lost.v2.openapi(contract.followOrder, (c) => { const order = findOrder(c.req.valid('param').id); if (!order) return httpProblem(c, 404, 'No such order');
return streamSSE(c, async (stream) => { await stream.writeSSE({ event: 'status', data: JSON.stringify(order) }); const notify = async (changed: Order) => { if (changed.id !== order.id) return; await stream.writeSSE({ event: 'status', data: JSON.stringify(changed) }); }; orderChanges.on('change', notify); // It waits until the client leaves; then it stops listening. await new Promise<void>((left) => stream.onAbort(left)); orderChanges.off('change', notify); });});Word by word:
- The
404comes before starting. Once the first line,200 OK, has gone out, the status code can no longer change. streamSSE(c, async (stream) => { … }), fromhono/streaming, sets the SSE headers and gives youstream, the open response, which lasts as long as that function takes to finish.stream.writeSSE({ event, data })writes theevent:anddata:lines and the blank line.JSON.stringifyturns the order into text (lesson 2 of Phase 3).notifysubscribes to the board and only writes if the order that changes is this connection’s.await new Promise<void>((left) => stream.onAbort(left)): a PromiseA value that isn’t there yet but will arrive, like the text of a file that is being read. Until it arrives, the program can go on with other things; with await, it waits for it.Go to definition that’s fulfilled when the client leaves. Meanwhile, the function doesn’t finish and the response stays open, without blocking the server: it’s the same old event loop..off('change', notify)removes the function from the board when the client leaves. Without this line, each closed connection would leave its function behind, and memory would grow without end.
At the end of the file, v2.all('/orders/:id/events', …) answers 405 to any other method.
WebSockets: the connection switches protocols
Section titled “WebSockets: the connection switches protocols”A chat, a game or a document two people edit at once need both directions. That’s what WebSocketA protocol for the client and the server to send each other messages in both directions, whenever they want, over a single connection that stays open. It starts as an HTTP request that asks to switch protocols, and the server accepts with status code 101.Go to definition is for, another ProtocolAn agreement on how two programs communicate: which messages they send, in what format, in what order and what to do if something goes wrong. HTTP, TCP and DNS are protocols.Go to definition, which starts as an HTTP request:
- Server → Client101 Switching Protocols
- Client · Serverfrom here on, it's no longer HTTP
- Server → ClientHi. Type something and I'll send it back.
- Server → Clientecho: hi
- The client asks to switch with
Upgrade: websocketandSec-WebSocket-Key, a random text. - The server accepts with
101 Switching ProtocolsandSec-WebSocket-Accept, a HashA short, fixed-size summary calculated from some data, like a fingerprint. The same data always gives the same hash, and the smallest change gives a completely different one. Git calls each commit by its hash.Go to definition of that key: it proves it really speaks WebSocket. It isn’t security: anyone can calculate it. - From then on, the same TCPTCP stands for Transmission Control Protocol.The transport layer protocol that makes data arrive complete and in order, and at the right program thanks to ports.Go to definition connection carries messages, not requests: each side sends whenever it wants, with no HTTP methods, status codes or headers.
Addresses start with ws://, or with wss:// with TLSTLS stands for Transport Layer Security.The protocol that encrypts a connection and uses a certificate to prove the server is who it claims to be. It sits between TCP and HTTP, and HTTP over TLS is HTTPS.Go to definition, like http:// and https://.
The echo, on the same port as the API
Section titled “The echo, on the same port as the API”The shop’s echo sends back whatever you send it. The WebSocket work is done by ws, the most widely used Package (of code)Ready-to-use code that someone publishes with a name and a version number, so others can install it in their projects instead of writing it. In Node.js, packages are installed with npm and kept in the node_modules folder.Go to definition for that in Node. First, the startup, src/server.ts, with what’s new highlighted:
import { serve } from '@hono/node-server';import { WebSocketServer } from 'ws';import { app } from './app.ts';import { config } from './config.ts';import { log } from './log.ts';
// ws does the WebSocket work. noServer: it doesn't open another port; the connections arrive// through the same one as the API, and Hono decides on which route they're accepted (/echo).const webSockets = new WebSocketServer({ noServer: true });
serve( { fetch: app.fetch, port: config.PORT, hostname: '127.0.0.1', websocket: { server: webSockets } }, (info) => { log.info(`The shop is listening on http://localhost:${info.port}`); },);new WebSocketServer({ noServer: true })sets upwswithout opening another PortA number, from 0 to 65535, that says which program on a computer a connection is for. The computer has an address; each listening program has its port.Go to definition: connections arrive through 3000, like the API.websocket: { server: webSockets }tellsserveto usewswhen a route accepts theUpgrade.
The echo is in a new file, src/echo.ts:
// An echo over WebSocket: what the client sends, the server sends back.import { upgradeWebSocket } from '@hono/node-server';
// The connection starts as a normal HTTP request (GET /echo, with Upgrade: websocket). The server// answers 101 Switching Protocols and, from then on, there are no more requests or responses: both// sides send messages whenever they want, over the same connection.export const echo = upgradeWebSocket(() => ({ onOpen(_event, ws) { ws.send("Hi. Type something and I'll send it back."); }, onMessage(event, ws) { ws.send(`echo: ${event.data}`); },}));upgradeWebSocket, from@hono/node-server, turns a route into a door to WebSocket, with a function for each event.onOpenis called when the connection opens: the server says hello without anyone asking.onMessage, with each message:event.datais its content, andws.sendreplies.
And the route, in src/app.ts, with import { echo } from './echo.ts'; at the top:
// If the request asks to switch to WebSocket, echo takes the connection. If not, the route says// that only WebSocket is spoken here: 426 Upgrade Required.app.get('/echo', echo, (c) => httpProblem(c, 426, 'This route only speaks WebSocket', { Upgrade: 'websocket' }),);If the request carries Upgrade: websocket, echo takes it; if not, the next function answers 426 Upgrade Required with the header Upgrade: websocket: only WebSocket is spoken here.
What a WebSocket costs
Section titled “What a WebSocket costs”- Everything HTTP gives you stays at the door. Without status codes or Problem Details, you make up the format of the messages and of the errors yourself.
- Reconnecting is up to you.
EventSourcecomes back on its own; the browser’sWebSocketdoesn’t. - Each connection lives on one server. With several, the notification has to reach the one holding that client’s connection: a scaling problem, for Phase 9.
SSE has a limit too: with HTTP/1.1, the browser opens at most 6 connections to each domain, counting all tabs, and each EventSource takes one. With HTTP/2 they share a single one.
Which one to use for what
Section titled “Which one to use for what”| Who talks | Use it for | |
|---|---|---|
| Polling | The client asks every so often | Slow changes, or a server you can’t touch |
| Server-Sent Events | The server, through an open response | Statuses, notifications, progress, an AI’s answers word by word |
| WebSocket | Both, whenever they want | Chats, games, editing together |
| Webhook (lesson 7) | One server calls another | Notifications between servers, like the payment gateway’s |
If only the server talks, SSE is usually enough, and it’s simpler: it’s HTTP and it reconnects on its own. AI model APIs send their answers piece by piece with SSE (Phase 11).
Try it
Section titled “Try it”The goal: watch an order go from pending to paid without asking again, in the terminal and in the browser, and talk to the echo. You start from your project from lesson 7, in ~/backend-course/phase-3/shop-api. If you get stuck, compare it with this lesson’s folder: from ~/backend-course/phase-3, curl -O https://backenddesdecero.com/practicas/shop-api/17-realtime.tar.gz, tar -xzf 17-realtime.tar.gz and, inside it, npm install.
Install ws and write the code
Section titled “Install ws and write the code”Install ws and its types
npm install ws@8.22.0npm install --save-dev @types/ws@8.18.2What you will see:
added 1 package, and audited 38 packages in 782ms
6 packages are looking for fundingrun `npm fund` for details
found 0 vulnerabilities
added 1 package, and audited 39 packages in 809ms
6 packages are looking for fundingrun `npm fund` for details
found 0 vulnerabilities@types/ws brings the TypeThe kind of data that can go in a place, such as a number, a piece of text or a product with its name and its price. In TypeScript it’s written after a colon (price: number), and it helps find errors before running the program.Go to definition for ws, with --save-dev, as in lesson 3 of Phase 3. This lesson’s outputs come from Node 26; your times, ids and dates will be different.
Then, write the code from “How it really works”:
- In
src/data.ts,import { EventEmitter } from 'node:events';at the top, and the board andchangeStatusafterprocessedEvents. - In
src/v2.ts,import { streamSSE } from 'hono/streaming';, andchangeStatus,orderChangesandtype Orderin theimportfrom./data.ts. Change the two lines that wroteorder.statusand add the route and its405. - The route in
src/contract.ts,src/echo.ts, its route insrc/app.tsand the newsrc/server.ts.
If you downloaded this lesson’s folder, copy its test/ into yours and npm test will check your code. Start the server with npm run dev.
Follow an order with curl
Section titled “Follow an order with curl”You’ll use three terminals: the server’s, one to follow the order and another to change it. In the second one:
1. Follow order 25 (and don't close the terminal)
curl -N -i localhost:3000/v2/orders/25/eventsWhat you will see:
HTTP/1.1 200 OKcache-control: no-cacheconnection: keep-alivecontent-type: text/event-streamtransfer-encoding: chunkedvary: Originx-request-id: 12e52baf-027c-4966-9956-838f69c108a7Date: Tue, 13 Oct 2026 15:39:20 GMT
event: statusdata: {"id":25,"productId":2,"quantity":2,"status":"pending","createdAt":"2026-10-08T09:00:00.000Z"}
event: statusdata: {"id":25,"productId":2,"quantity":2,"status":"paid","createdAt":"2026-10-08T09:00:00.000Z"}
event: statusdata: {"id":25,"productId":2,"quantity":2,"status":"cancelled","createdAt":"2026-10-08T09:00:00.000Z"}At first you’ll see the headers and the first event, pending, and curl keeps waiting: the response hasn’t finished. The other two events arrive with steps 2 and 3.
-N makes curl write each piece as soon as it arrives; without it, it may hold on to them and show you the events late.
2. In the third terminal: the gateway pays for the order
npm run gateway -- 25What you will see:
> shop-api@1.0.0 gateway> node --env-file-if-exists=.env scripts/payment-gateway.ts 25
→ POST /v2/webhooks/payments {"id":"evt_b1099330-fee2-4009-b4b8-3616420d60d9","type":"payment.completed","orderId":25}← 200 {"received":"evt_b1099330-fee2-4009-b4b8-3616420d60d9","repeated":false}Lesson 7’s fake payment gateway sends its signed webhook, and in the second terminal the paid event appears without curl having asked anything.
If the gateway gets its 200 but the event doesn’t appear, check that the webhook calls changeStatus and doesn’t change order.status by hand.
3. Cancel the order
curl -i -X POST localhost:3000/v2/orders/25/cancellationWhat you will see:
HTTP/1.1 200 OKcontent-type: application/jsonvary: Originx-request-id: 2d6c0776-955e-4504-a672-77149ac0723econtent-length: 96Date: Tue, 13 Oct 2026 15:39:27 GMTConnection: keep-aliveKeep-Alive: timeout=5
{"id":25,"productId":2,"quantity":2,"status":"cancelled","createdAt":"2026-10-08T09:00:00.000Z"}And in the second terminal, the cancelled event. Close curl with Ctrl + C. Notice: this response has content-length: 96 and ends; the SSE one had no length.
In the server’s terminal, the log records the first request with "ms":4, even though it lasted several seconds: streamSSE hands over the response right away, with the events still to be written, and the log records it then.
Challenge: follow order 3, which is shipped, and try to cancel it. What does the cancellation answer, and what shows up in curl’s terminal?Show answer
curl -N localhost:3000/v2/orders/3/events # in one terminalcurl -w '\n' -X POST localhost:3000/v2/orders/3/cancellation # in another{"type":"https://shop.example/problems/order-status","title":"The order's status doesn't allow it","status":409,"detail":"The order is already shipped: it cannot be cancelled"}409: a shipped order can’t be cancelled. And curl receives nothing after the first event, shipped: nobody has called changeStatus.
Follow an order from the browser
Section titled “Follow an order from the browser”Open http://localhost:3000/ in Chrome and, in DevTools (how to open it), the Console tab. It has to be a page from http://localhost:3000: the API’s CORSCORS stands for Cross-Origin Resource Sharing.The way a server tells the browser which other origins may read its responses from a page’s code, with headers such as Access-Control-Allow-Origin. The browser enforces it, not the server.Go to definition only lets https://shop.example read. If Chrome asks you to type allow pasting, do it, as in the CORS lesson.
In the console: follow order 24
const source = new EventSource('/v2/orders/24/events')source.addEventListener('status', (event) => console.log(event.data))What you will see:
{"id":24,"productId":1,"quantity":1,"status":"pending","createdAt":"2026-10-08T02:00:00.000Z"}new EventSource('…') opens the connection, and addEventListener('status', …) subscribes a function to the status events; event.data is the text of its data: line.
Paste the two lines together: with the first one alone, the first event may arrive before the second one subscribes the function. The undefined the console writes doesn’t matter.
Now, in the terminal, npm run gateway -- 24: the paid order appears in the console.
Now stop the server with Ctrl + C. Red errors appear in the console, net::ERR_CONNECTION_REFUSED, every 3 seconds: it’s EventSource trying to come back. Start it again with npm run dev and, a few seconds later, a new event arrives without touching the console.
But it says pending: the data was in memory and was lost when the server stopped (the database arrives in Phase 5). Reconnection works; the server sends the status it has now.
Talk to the echo
Section titled “Talk to the echo”First, the HTTP request from the beginning. curl doesn’t speak WebSocket, but it shows the response:
1. Ask to switch protocols
curl -i -H 'Connection: Upgrade' -H 'Upgrade: websocket' \-H 'Sec-WebSocket-Version: 13' -H 'Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==' \localhost:3000/echoWhat you will see:
HTTP/1.1 101 Switching ProtocolsUpgrade: websocketConnection: UpgradeSec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=vary: Origin
�)Hi. Type something and I'll send it back.The \ at the end of a line continues the command on the next one. The key is the one from the standard’s example (RFC 6455), and s3pPLMBiTxaQ9kYGzzhZRbK+xOo= is the answer the standard gives for it.
The last line is no longer HTTP: it’s the echo’s greeting, a WebSocket message, with its header in front: two characters your terminal may draw differently. curl keeps waiting: close it with Ctrl + C.
In the log, this request shows up with "status":200: the log sees the response Hono prepares, but the 101 is written by ws directly on the connection.
2. Without asking to switch
curl -i localhost:3000/echoWhat you will see:
HTTP/1.1 426 Upgrade Requiredcontent-type: application/problem+jsonupgrade: websocketvary: Originx-request-id: 0c3047cb-1b75-4e70-819b-3167728eeea2content-length: 106Date: Tue, 13 Oct 2026 15:39:47 GMTConnection: keep-aliveKeep-Alive: timeout=5
{"type":"about:blank","title":"Upgrade Required","status":426,"detail":"This route only speaks WebSocket"}A normal GET gets a 426, in Problem Details like any error from the API, and upgrade: websocket says which protocol is needed.
To really talk you need a WebSocket client, and Node 26 comes with the same one as the browser:
3. A WebSocket client with Node
node -e 'const ws = new WebSocket("ws://localhost:3000/echo");ws.onopen = () => ws.send("hi");ws.onmessage = (event) => console.log(event.data);setTimeout(() => ws.close(), 1000);'What you will see:
Hi. Type something and I'll send it back.echo: hinode -e runs the code between the quotes: when the connection opens (onopen) it sends hi, writes each message that arrives (onmessage) and closes after one second (setTimeout).
Two messages arrive: the greeting, which the server sends without anyone asking, and the echo of hi: both directions, over a single connection.
You have already seen it
Section titled “You have already seen it”- An AI that writes its answer word by word, the delivery driver moving on the map or a chat’s “is typing…”: changes that arrive without reloading.
- In DevTools’ Network tab, a request that stays “pending” for a long time may be a connection left open on purpose.
EventSourceones have the EventStream tab, and WebSocket ones, Messages, with what goes out and what comes in.
Common mistakes
Section titled “Common mistakes”- Listening with
onmessagewhen the events have a name. It only receives the ones withoutevent:; the shop’s events needaddEventListener('status', …). - Forgetting
.offwhen the client leaves. The functions of closed connections pile up, and memory grows until it brings the server down. - Checking for errors after starting the stream. With the
200already sent, a404comes too late. - A proxy that holds on to the response. nginx, by default, gathers it before passing it on, and the events arrive all at once. For SSE it’s turned off with
proxy_buffering off(Phase 8).
Summary
Section titled “Summary”- Asking every few seconds (polling) wastes requests and arrives late. Better for the client to open a connection and the server to write through it.
- Server-Sent Events is an HTTP response that doesn’t end:
text/event-stream, events made ofevent:anddata:lines closed by a blank line, andEventSource, which reconnects on its own. - The shop’s route sends the current status, subscribes to an
EventEmitterand unsubscribes with.offwhen the client leaves. - WebSocket starts with
Upgradeand a101 Switching Protocols; after that, both sides send messages whenever they want. - If only the server talks, SSE; if both talk, WebSocket; between servers, webhooks.
Did you get it?
Section titled “Did you get it?”To review:
Further reading
Section titled “Further reading”- Using server-sent events (MDN): the format,
EventSourceand reconnection. - The WebSocket API (MDN): the browser’s client.
- Server-sent events (WHATWG): the standard, inside HTML’s.
- RFC 6455: The WebSocket Protocol: the protocol switch and the example key.
- Streaming Helper and WebSocket Helper (Hono):
streamSSEandupgradeWebSocket.