Skip to content
tezvyn:

Networking

137 bites tagged Networking — interview questions with model answers, and 60-second explainers.

Android & Kotlin2 min read

What is certificate pinning and what are its trade-offs?

Pinning hardcodes a server key to block rogue CA MITM; trade-offs are breakage on cert rotation and forced updates. Understanding TLS trust chain attacks beyond HTTPS.

Android & Kotlin2 min read

How do you make a network request in an Activity using coroutines?

This tests main thread safety and coroutine dispatchers. A strong answer cites NetworkOnMainThreadException, uses lifecycleScope, and switches to Dispatchers.IO. Red flag: suggesting Dispatchers.Main for the network call or omitting the exception entirely.

Android & Kotlin2 min read

Configure OkHttp Cache for Retrofit and force network requests

This tests HTTP caching semantics in mobile networking. A strong answer covers Cache setup with a 50 MiB directory, server Cache-Control driving expiration, and CacheControl.FORCE_NETWORK to bypass.

Analytics & Metrics2 min read

Design a Client-Side Event Batching System

Tests your grasp of client-side performance, network optimization, and data loss edge cases. A great answer batches events in memory, sends them with `fetch()`, and uses `navigator.sendBeacon()` on `pagehide` to reliably send the final batch.

Android & Kotlin2 min read

OkHttp Interceptors: Middleware for Your Network Stack

OkHttp Interceptors act as middleware for your network stack, letting you observe, modify, or short-circuit requests and responses. Use them to automatically add auth tokens or log traffic. The main footgun is order: application interceptors run once per call.

TypeScript & Web APIs2 min read

RTCPeerConnection: Direct Browser-to-Browser Links

Think of an RTCPeerConnection as a direct phone line between two browsers. It's the core of WebRTC, enabling peer-to-peer video and data streams. The footgun: it doesn't find peers; you must use a separate signaling server to broker the initial handshake.

TypeScript & Web APIs2 min read

Intercept Network Requests with the `fetch` Event

The `fetch` event turns your Service Worker into a programmable network proxy. Use it to intercept outgoing requests to serve assets from a cache for offline support or to synthesize custom responses.

TypeScript & Web APIs2 min read

Fetch API: Making Basic Network Requests

The Fetch API is like ordering from a catalog: you give it a URL and get a promise of delivery. It's used to load data from APIs without a page reload. The footgun: the promise resolves even on HTTP errors (like 404); you must check.

React Native2 min read

React Native NetInfo: Know Your Connection State

The NetInfo API is your app's network sensor, telling you if you're online and whether you're on WiFi or cellular. Use it to show an 'offline' banner or defer large downloads. The main footgun: `isConnected` only confirms a local link, not server reachability.

React Native2 min read

WebSockets: A Persistent, Two-Way Connection

Think of a WebSocket as a dedicated phone line to a server, keeping the connection open for two-way conversation. It's ideal for real-time features like live chat or streaming stock tickers.

React Native2 min read

FormData: The Right Way to Upload Files

FormData is your digital envelope for file uploads. It packages files and text into a `multipart/form-data` payload for `fetch`. Use it in React Native to upload images or videos. The footgun: don't set the `Content-Type` header yourself; `fetch` handles it.

React Native2 min read

Axios Interceptors: Middleware for Your API Calls

Axios Interceptors are like middleware for your API calls, letting you globally modify requests before they're sent or responses before they're handled. Use them to inject auth tokens or log activity. The footgun: request interceptors run last-in-first-out.

React Native2 min read

Axios: A Simpler Way to Make HTTP Requests

Axios simplifies making network requests by wrapping native browser APIs in a promise-based client. Use it to GET or POST data in any JavaScript app. The main footgun is forgetting requests are asynchronous; you must use `async/await` to get the data.

React Native2 min read

React Native: Making Network Requests with Fetch

fetch is your app's tool for requesting server data. It's asynchronous, returning a promise for a future response. Use it for API calls like loading profiles or posting updates. The footgun: always `catch` errors, or they will fail silently.

Python & FastAPI2 min read

asyncio Streams: High-Level Async Network I/O

asyncio Streams are like async file handles for the network. You get a reader/writer pair to await data, simplifying TCP clients and servers for basic protocols. The footgun: the default buffer limit is small; reading large data will fail unexpectedly.

Python & FastAPI2 min read

FastAPI's WebSocket State Machine

FastAPI manages WebSockets with a state machine, tracking client and application states separately. You must explicitly `accept()` a connection before communicating. This is key for chat or notification features.

Python & FastAPI2 min read

FastAPI Behind a Reverse Proxy: Fixing Docs URLs

A reverse proxy can hide the full URL from your FastAPI app, breaking OpenAPI docs. Tell your app about the proxy's path prefix by setting the `root_path` during initialization to ensure all generated URLs are correct.

Python & FastAPI2 min read

CORSMiddleware: Unblocking Your Frontend from Your Backend

CORS is a browser security rule, not a server bug. Use FastAPI's CORSMiddleware to tell browsers which frontends (e.g., `localhost:3000`) are allowed to fetch data from your API (e.g., `localhost:8000`).

Python & FastAPI2 min read

asyncio: Transports Move Bytes, Protocols Decide Which Bytes

asyncio Transports are the "how" (moving bytes), while Protocols are the "what" (deciding which bytes to send). They're the low-level foundation for libraries handling raw socket I/O.

Node.js & Express2 min read

Socket.IO Namespaces: Channels on One Connection

Socket.IO namespaces are virtual channels over a single WebSocket connection, letting you split app logic without multiple connections. Use them for separate areas like `/admin` or for multi-tenancy.

Node.js & Express2 min read

Server-Sent Events (SSE): One-Way Data Push from Server

Server-Sent Events (SSE) push data from server to client over one HTTP connection. It's a simpler, one-way alternative to WebSockets for things like live news feeds or status updates.

Node.js & Express2 min read

The 'ws' Library: WebSockets for Node.js Servers

The `ws` library is the standard for adding WebSocket servers to Node.js for real-time features like chat or live data feeds. It provides both server and client APIs for backend-to-backend communication.

Node.js & Express2 min read

Socket.IO: More Than Just WebSockets

Socket.IO is a library that guarantees real-time, bidirectional communication. It automatically picks the best transport—WebSocket or HTTP long-polling—to ensure your connection works. Use it for chat apps or live dashboards.

Node.js & Express2 min read

Polling vs. WebSockets: Stop Asking, Start Listening

Polling is like repeatedly asking "Are we there yet?", while WebSockets is a persistent, two-way conversation. Use polling for infrequent updates, but use WebSockets for real-time apps like chat. The footgun is using polling for high-frequency updates.

Get Networking bites daily.

Five a day, five minutes, offline. With quizzes so it sticks.

Open testing — you’ll join as an early tester.