← All Learning Paths

WebSocket Developer

Ship real-time features that survive proxies: heartbeat design, exponential reconnect, hub broadcast patterns, and the 1006 closures nobody logs properly.

roleintermediate9 nodes13.58h total

Path overview

WebSocket 的难点从来不是握手,而是断线之后的每一件事。本路径从长轮询对比建立选型意识,经心跳与指数退避重连的设计文章,到四种语言栈的 Hub 广播实现,收尾于 1006 异常断连与代理 Upgrade 失败两大经典故障。

The hard part of WebSocket is everything after the disconnect. This path covers polling trade-offs, heartbeats, exponential reconnect, hub broadcast in four stacks, and the classic 1006 and proxy-upgrade failures.

  1. Read "Building Real-time Features with WebSockets" for the "Backpressure and Message Framing" argument, then name the decision in websocket work it would change.

    Completion criteria: Write a five-line decision note citing "Backpressure and Message Framing" from "Building Real-time Features with WebSockets", name the option you rejected, and attach the before/after diff of one file you changed.

    Next step: How to Implement WebSocket Heartbeats and Reconnects

    ⏱ 1h

  2. Compare "Heartbeat with control frames" with "Client implementation" in "How to Implement WebSocket Heartbeats and Reconnects" and state which trade-off you would accept in websocket code.

    Prerequisites: Building Real-time Features with WebSockets

    Completion criteria: Attach a one-page summary that quotes "Heartbeat with control frames", lists two trade-offs, and links the commit where you applied it.

    Next step: WebSocket Client With Exponential Reconnect

    ⏱ 1h

  3. Execute "WebSocket Client With Exponential Reconnect", change one constant, and describe how the output diverges from "Keep a WebSocket client alive through disconnects with exponential backoff reconnect,".

    Prerequisites: How to Implement WebSocket Heartbeats and Reconnects

    Completion criteria: Attach the terminal transcript for "WebSocket Client With Exponential Reconnect": command, exit code, and the printed result you used to confirm "Keep a WebSocket client alive through disconnects with exponential backoff reconnect,".

    Next step: Gorilla WebSocket Hub Room Broadcast

    ⏱ 0.75h

  4. Run the websocket snippet "Gorilla WebSocket Hub Room Broadcast", capture stdout, and show which line demonstrates the documented behavior: "Run a hub that registers WebSocket clients into rooms, broadcasts messages to a room, and".

    Prerequisites: WebSocket Client With Exponential Reconnect

    Completion criteria: Change one constant in "Gorilla WebSocket Hub Room Broadcast", rerun, and attach both stdout captures plus a one-line diff explaining what moved.

    Next step: WebSocket Ping Pong Heartbeat

    ⏱ 0.75h

  5. Adapt "WebSocket Ping Pong Heartbeat" to a second input and compare the new output with the behavior described in "Keep WebSocket connections alive with application-level ping frames, tracking liveness with".

    Prerequisites: Gorilla WebSocket Hub Room Broadcast

    Completion criteria: Paste the command, the exit code, and the output line matching "Keep WebSocket connections alive with application-level ping frames, tracking liveness with"; then show a second run with a changed parameter.

    Next step: FastAPI WebSocket Broadcast Manager

    ⏱ 0.75h

  6. Execute "FastAPI WebSocket Broadcast Manager", change one constant, and describe how the output diverges from "Manage WebSocket connections in FastAPI with a connection registry, broadcasting to all".

    Prerequisites: WebSocket Ping Pong Heartbeat

    Completion criteria: Save two runs of "FastAPI WebSocket Broadcast Manager" side by side — the original input and one changed value — and annotate the line where the output diverges.

    Next step: Tokio Tungstenite WebSocket Split

    ⏱ 0.75h

  7. Run the websocket snippet "Tokio Tungstenite WebSocket Split", capture stdout, and show which line demonstrates the documented behavior: "Split a WebSocket stream into independent sink and stream halves, running concurrent send".

    Prerequisites: FastAPI WebSocket Broadcast Manager

    Completion criteria: Change one constant in "Tokio Tungstenite WebSocket Split", rerun, and attach both stdout captures plus a one-line diff explaining what moved.

    Next step: Decide WebSocket Reconnect from Heartbeat Misses

    ⏱ 0.75h

  8. Solve "Decide WebSocket Reconnect from Heartbeat Misses" for websocket work: turn JSON object: { heartbeatIntervalMs, missedPongs, threshold } into {action:ping-again,waitMs:30000} and pass both samples.

    Completion criteria: Submit a solution for "WebSocket Developer" that passes both samples ({heartbeatIntervalMs:30000,missedPongs:1,threshold:2} to {action:ping-again,waitMs:30000}) and attach the failing case you fixed.

    Next step: Capstone: WebSocket Developer

    ⏱ 0.33h

  9. Ship "Room router" from "Build a WebSocket Presence Server", then prove it with the project's test suite and an acceptance note.

    Prerequisites: Decide WebSocket Reconnect from Heartbeat Misses

    Completion criteria: Run the project's test command for "Build a WebSocket Presence Server", paste the passing output, and attach the acceptance note for "Room router" with the test name.

    Next step: Run the capstone's tests, publish the repository, and demo it to a reviewer.

    ⏱ 4h