The 51 diagrams from Designing Cloud-Native APIs: WebSockets, in reading order. Each one renders
inline here and ships a paired .excalidraw source you can
open on excalidraw.com and edit.
Figure 0.1: The lab: one contract, two servers, OTel off by default.
Figure 4.1: The handling-event feed: the REST booking service's write path triggers a push; its read path, GET /bookings/{id}, still answers on request.
Figure 7.2: a connection opened before t0 outlives the deploy that changed the contract; the dual-publish window is what keeps it alive and correct until it reconnects or the server closes it as planned.
Figure 9.2: contracts/asyncapi.yaml becomes app/models_generated.py's Pydantic model at build time; nothing hand-written sits between the contract and the wire frame.
Figure 10.1: the reconnect state machine both clients implement, connected, dropped, backoff with jitter, retry, and either success (attempt resets) or another lap through the same loop.
Figure 12.1: a producer outrunning a consumer: the client's TCP window fills first, then the server's own send calls back up behind it, until one of the two signals trips the configured policy.
Figure 12.2: the bounded outbound buffer sitting between the producer and the socket write, and the two policies for what happens once one of the two trigger conditions fires.
Figure 13.1: the one decision CloseCodes.java's Javadoc states for every failure on this channel: is there a specific frame to annotate, while the socket is still open?
Figure 13.2: the envelope-then-close sequence this chapter builds, next to the one failure mode no close code can ever carry: a peer that vanished before any handshake could complete.
Figure 14.1: the idle-timeout trap (the server's own ping keeps resetting its own idle clock) versus the pong-tracked sweep that detects a silent peer.
Figure 14.2: the real timeline from last pong to the TCP socket closing: detection at the liveness timeout, then up to ten more seconds of closing-handshake grace before onClose observes 1006.
Figure 15.1: the stateless gap: an event injected during the disconnect window is never queued and never stored, so reconnecting with afterEventId resumes the socket, not the missing event.
Figure 15.2: the decision: stateless reconnect is fine when a fresh value supersedes a stale one or a full resync is cheap, and not enough when every event is individually significant and the feed is the only record of it.
Figure 16.1: the topic/offset/resume model: the seed never touches Kafka, only injected events are keyed into the topic by bookingId, and an afterEventId that names a seed id always falls back to replaying everything currently in the topic.
Figure 16.2: the same disconnect/inject/reconnect sequence as the stateless-reconnect example, but a durable topic behind the socket turns 'lost' into 'filled, exactly once.'
Figure 17.1: both stacks accept the handshake, then validate the token as the first thing the handler does, closing 1008 before any fixture frame goes out; Python's process_request hook exists but runs too early to issue that close code.
Figure 17.2: this chapter's self-minted HS256 shared secret and the Keycloak/OIDC RS256-plus-JWKS path both put a bearer JWT at the upgrade; only the trust model behind the signature differs.
Figure 18.1: a sticky load balancer pins the client to instance A, but the event enters at instance B; without a shared backplane the event never crosses the gap between them.
Figure 18.2: Kafka and Redis both close the fan-out gap; the difference is what each one gives up to do it cheaply (Redis) or durably (Kafka), not whether the client gets the event.
Figure 19.1: one HandlingEvent, two wire encodings negotiated by subprotocol; the frame opcode tells the receiving end which decoder to use before it reads a single byte.
Figure 19.2: a JSON key can be renamed freely because the string itself is the identity; a Protobuf field number can never move or be reused, because the integer tag, not the field's name, is the wire identity.
Figure 20.1: the measured bytes/frame comparison and the real stack difference in whether permessage-deflate gets negotiated at all; the deflate row's bytes/frame is a blind spot, not evidence against compression.
Figure 21.1: the WebSocket test pyramid: five tools across four tiers, narrower and slower toward the top, all gated on the same contract-derived schema.
Figure 22.1. Where each tool taps a live connection: the handshake, the data frames, and the close, plus the TCP layer every one of them sits on top of.
Figure 23.1: Quarkus adds a manual child span under an auto-traced HTTP upgrade; Python has no auto-traced layer at all, so the whole connection span is hand-written with the SDK tracer directly.
Figure 23.2: only the trace gets pushed over OTLP to Tempo in this example; the metric and the log line both stay local to the process, pulled or read directly, and the trace id is what bridges them back to the trace a human or verify.sh can query.
Figure 24.2: the idle-timeout trap doesn't show up in a quick manual test; it shows up only once a connection lives long enough for a silent peer's own ping-driven clock reset to matter, which is exactly the timescale a short dev session never reaches.