Client disconnect cleanup
Learn how to notice when a WebSocket client disconnects and remove it from the shared connection set so dead clients do not pile up
A WebSocket server holds one open connection per client. When a client leaves, that connection has to be noticed and cleaned up, or the server slowly fills with dead entries: connections that will never send again, names in a list that no longer exists, and memory that is never returned. Cleanup is the code that runs when the receive loop ends. It removes the client from whatever shared state the server keeps, stops the tasks that served it, and leaves the server exactly as it was before that client arrived.
Where This Fits
The previous page split each connection into a sender task and a receiver task. This page is about the moment those tasks end: the client disconnects, the receiver loop finishes, and the server must tidy up after it. Think of a hotel front desk. Checking a guest in means writing their name in the register. Checking a guest out means crossing the name out. A register that only ever gains names will eventually list guests who left long ago, and the hotel will think it is full when half the rooms are empty.
The Smallest Working Version First
Here is a complete server that keeps a set of connected clients and prints the size of the set as clients come and go. A plain HTTP route reports the count, so the cleanup is visible from outside.
# Cargo.toml
[package]
name = "ws-learn"
version = "0.1.0"
edition = "2021"
[dependencies]
axum = { version = "0.8.9", features = ["ws"] }
tokio = { version = "1.54.1", features = ["full"] }
dashmap = "6"
// src/main.rs
use axum::{
extract::{
ws::{Message, WebSocket, WebSocketUpgrade},
State,
},
response::Response,
routing::{any, get},
Router,
};
use dashmap::DashMap;
use std::sync::{
atomic::{AtomicU64, Ordering},
Arc,
};
#[derive(Clone)]
struct AppState {
clients: Arc<DashMap<u64, ()>>,
next_id: Arc<AtomicU64>,
}
async fn ws_handler(ws: WebSocketUpgrade, State(state): State<AppState>) -> Response {
let id = state.next_id.fetch_add(1, Ordering::Relaxed);
state.clients.insert(id, ());
println!("client {id} connected, total now {}", state.clients.len());
ws.on_upgrade(move |socket| handle_socket(socket, state, id))
}
async fn handle_socket(mut socket: WebSocket, state: AppState, id: u64) {
while let Some(msg) = socket.recv().await {
match msg {
Ok(Message::Text(text)) => {
println!("client {id} says: {text}");
}
Ok(Message::Close(_)) => break,
Ok(_) => {}
Err(_) => break,
}
}
state.clients.remove(&id);
println!("client {id} removed, total now {}", state.clients.len());
}
async fn count(State(state): State<AppState>) -> String {
state.clients.len().to_string()
}
#[tokio::main]
async fn main() {
let state = AppState {
clients: Arc::new(DashMap::new()),
next_id: Arc::new(AtomicU64::new(1)),
};
let app = Router::new()
.route("/ws", any(ws_handler))
.route("/count", get(count))
.with_state(state);
let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
.await
.unwrap();
println!("Listening on http://127.0.0.1:3000");
axum::serve(listener, app).await.unwrap();
}
Run it with cargo run. Then connect a client, watch the count, disconnect, and watch it again. The client below connects, sends one message, closes cleanly, and reads the count before and after through the plain /count route.
// src/bin/ws_client.rs
use futures_util::{SinkExt, StreamExt};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio_tungstenite::{connect_async, tungstenite::Message};
async fn get_count() -> String {
let mut stream = tokio::net::TcpStream::connect("127.0.0.1:3000")
.await
.unwrap();
stream
.write_all(b"GET /count HTTP/1.1\r\nHost: 127.0.0.1:3000\r\nConnection: close\r\n\r\n")
.await
.unwrap();
let mut buf = Vec::new();
stream.read_to_end(&mut buf).await.unwrap();
let text = String::from_utf8_lossy(&buf).into_owned();
text.split("\r\n\r\n").nth(1).unwrap_or("?").trim().to_string()
}
#[tokio::main]
async fn main() {
let (ws, _) = connect_async("ws://127.0.0.1:3000/ws").await.unwrap();
let (mut write, _read) = ws.split();
tokio::time::sleep(std::time::Duration::from_millis(300)).await;
println!("count while connected: {}", get_count().await);
write.send(Message::Text("hi".into())).await.unwrap();
write.close().await.unwrap();
drop(_read);
drop(write);
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
println!("count after disconnect: {}", get_count().await);
}
This client needs tokio-tungstenite = "0.28" and futures-util = "0.3" in Cargo.toml. Run it with cargo run --bin ws_client while the server is running. The live run printed:
count while connected: 1
count after disconnect: 0
And the server printed:
client 1 connected, total now 1
client 1 says: hi
client 1 removed, total now 0
The count goes up by one when the client connects and back down to zero when it leaves. That round trip is the whole point of the page. A server that cannot show that round trip has a leak.
The Count Is the Proof:
If the count returns to zero after the client disconnects, cleanup works. If it stays at one, the removal line never ran, and every future client will add another permanent entry. Watch the count, not just the log lines: the count is the state, and the log is only a story about it.
The Shared Set, Piece by Piece
The state in this example has two fields, and each one earns an explanation because both are doing a specific job.
#[derive(Clone)]
struct AppState {
clients: Arc<DashMap<u64, ()>>,
next_id: Arc<AtomicU64>,
}
AppState is a plain struct that holds the data every connection needs to share. It derives Clone because Axum clones the state for every request, and cloning must be cheap. Both fields are cheap to clone because they are reference-counted pointers to shared data, not copies of the data itself.
clients is a DashMap<u64, ()>, a concurrent hash map from the dashmap crate. A hash map stores pairs of keys and values so a value can be found quickly by its key. Here the key is the client id, a number, and the value is (), the empty value, which means the map is being used as a set: only the presence of the key matters, not what it points to. A DashMap differs from a standard map in that many tasks can insert, remove, and read at the same time without taking a lock that blocks all of them. Each part of the map has its own lock, so two clients connecting at the same moment do not wait for each other. Arc is a shared pointer that lets many tasks own the same map: cloning the Arc gives another owner of the same map, not a copy of it.
next_id is an AtomicU64, a counter that many tasks can safely increment without a lock. fetch_add(1, Ordering::Relaxed) returns the current value and adds one to it, as a single uninterruptible step, so two clients connecting at the same moment always get different ids. Ordering::Relaxed is the weakest ordering guarantee, and it is enough here because the only requirement is that ids are unique, not that they are handed out in a particular order across threads.
The handler is where the id is born:
let id = state.next_id.fetch_add(1, Ordering::Relaxed);
state.clients.insert(id, ());
The id is taken before the upgrade, and the client is inserted into the map before on_upgrade runs. That ordering matters. If the insert happened inside the socket function, there would be a gap between the handshake and the insert during which the client is connected but not counted. A request to /count in that gap would report one fewer client than really exists. Inserting in the handler closes that gap: by the time the 101 response is sent, the client is already in the map.
The cleanup is the mirror image, and it sits after the loop:
state.clients.remove(&id);
The receive loop only ends when the client is gone. recv returns None when the connection closes cleanly, Err when it breaks, and the loop breaks early on a close frame. Every one of those paths reaches the line after the loop. That is what makes the line after the loop the cleanup point: it runs exactly once per connection, on every way out, with no other exit from the function. If the function had a second return hidden inside the loop, cleanup could be skipped. The shape of the function is the guarantee.
How the Server Notices a Disconnect
A disconnect is not an event the server is told about. It is something the server discovers by trying to use the connection and finding it gone. There are three ways that discovery happens, and each one ends the receive loop.
A clean close is the polite case. The client sends a close frame, which arrives as Message::Close. The loop in the example breaks on it. After the close frame, recv would return None anyway, so breaking early and letting recv return None are the same outcome: the loop ends, and cleanup runs.
A dropped connection is the silent case. The client process is killed, the network cable is pulled, or the laptop lid closes. No close frame is sent, because the client had no chance to send one. The server discovers this the next time it reads or writes. A read on a dead connection returns an error or None once the operating system notices the socket is gone. That discovery can take time, because the operating system only notices when it tries to use the socket or when its own keepalive probes fail. A server that only reads will notice a dead client on its next read. A server that also writes will notice it on its next failed write.
A failed send is the third case. socket.send returns an error when the connection is gone. Code that ignores send errors keeps a dead connection in its list and keeps trying to write to it. Code that treats a send error as a disconnect, and breaks out of its loop, cleans up promptly. In the split design from the previous page, the sender task learns about the disconnect this way, and the receiver task learns about it through recv. Either one ending is enough to start cleanup, as long as the ending task tells the other one to stop.
A Silent Client Can Look Alive for a While:
A client whose network vanished without a close frame can sit in the connection set until the server tries to read or write. The set is not a perfect live picture of the network. It is a picture of the connections the server has noticed ending. The keepalive timer on the next page exists to turn silent clients into noticed ones: it forces a write, and the write fails if the client is really gone.
The Concept Behind Cleanup
Every connection the server accepts is a small allocation of resources: a socket, a task, an entry in a map, and whatever else the handler holds. Those resources are borrowed from the server for the life of the connection, and the loan ends when the client leaves. Cleanup is returning the loan.
The failure mode without cleanup is slow and quiet. Nothing crashes. No error appears. The server just holds a little more memory after each client, and its counts drift further from reality. A broadcast that iterates over the connection set starts trying to write to dead sockets, and each failed write costs time. A dashboard that reports online users shows people who left hours ago. The damage is proportional to uptime, which is why cleanup bugs are usually found in production and rarely in testing: a test connects one client and disconnects once, and a leak of one entry is invisible.
A useful mental model is borrowing library books. The register records who has which book. Returning a book means crossing the entry out. A library that never crosses entries out will eventually believe every book is out, and it will stop lending. The register is not the books themselves, but it decides whether the library can function.
Why Removal Belongs After the Loop
There are two obvious places to put the removal: right after the loop, or in a separate cleanup function called from several places. The example puts it right after the loop, and the reason is control flow. The loop has exactly one exit that reaches the line after it, and every path out of the loop passes through that line. There is no way to leave the function without passing the removal.
The alternative, calling removal from inside the loop at each break point, is fragile. A new break added later by someone who does not know about the cleanup will skip it. A return added for an error case will skip it. The line after the loop cannot be skipped by accident, because it is the only way out. That is also why the function has no early return inside the loop: each outcome is a break, and the break lands on the cleanup line.
One more shape is worth knowing for larger handlers. If the cleanup grows beyond one line, wrap the whole socket function body so the cleanup runs no matter how the function ends. Rust has no finally block, but a small helper pattern gives the same guarantee: put the loop in an inner async block or function, and run cleanup after it returns. The principle is the same in every shape: one exit, one cleanup.
A Richer Example With a Named Set and a Goodbye Broadcast
The smallest example stores ids only. A richer version stores a channel sender per client, so the server can send a message to every connected client, and it announces arrivals and departures to the rest of the room. This is the shape a chat server actually uses, and it shows why cleanup matters beyond a count: a dead entry here is not just a wrong number, it is a channel nobody reads, and a broadcast to it will fail or block.
// src/main.rs
use axum::{
extract::{
ws::{Message, WebSocket, WebSocketUpgrade},
State,
},
response::Response,
routing::{any, get},
Router,
};
use dashmap::DashMap;
use futures_util::{sink::SinkExt, stream::StreamExt};
use std::sync::{
atomic::{AtomicU64, Ordering},
Arc,
};
use tokio::sync::mpsc;
#[derive(Clone)]
struct AppState {
clients: Arc<DashMap<u64, mpsc::Sender<Message>>>,
next_id: Arc<AtomicU64>,
}
async fn ws_handler(ws: WebSocketUpgrade, State(state): State<AppState>) -> Response {
let id = state.next_id.fetch_add(1, Ordering::Relaxed);
let (tx, rx) = mpsc::channel::<Message>(32);
state.clients.insert(id, tx);
broadcast(&state, &format!("client {id} joined, total now {}", state.clients.len())).await;
ws.on_upgrade(move |socket| handle_socket(socket, state, id, rx))
}
async fn broadcast(state: &AppState, text: &str) {
let dead: Vec<u64> = Vec::new();
let mut dead = dead;
for entry in state.clients.iter() {
let id = *entry.key();
let tx = entry.value().clone();
if tx.send(Message::text(text.to_string())).await.is_err() {
dead.push(id);
}
}
for id in dead {
state.clients.remove(&id);
}
}
async fn handle_socket(
socket: WebSocket,
state: AppState,
id: u64,
mut rx: mpsc::Receiver<Message>,
) {
let (mut sender, mut receiver) = socket.split();
let send_task = tokio::spawn(async move {
loop {
match rx.recv().await {
Some(message) => {
if sender.send(message).await.is_err() {
break;
}
}
None => break,
}
}
});
while let Some(msg) = receiver.next().await {
match msg {
Ok(Message::Text(text)) => {
broadcast(&state, &format!("client {id} says: {text}")).await;
}
Ok(Message::Close(_)) => break,
Ok(_) => {}
Err(_) => break,
}
}
send_task.abort();
state.clients.remove(&id);
broadcast(
&state,
&format!("client {id} left, total now {}", state.clients.len()),
)
.await;
println!("client {id} removed, total now {}", state.clients.len());
}
async fn count(State(state): State<AppState>) -> String {
state.clients.len().to_string()
}
#[tokio::main]
async fn main() {
let state = AppState {
clients: Arc::new(DashMap::new()),
next_id: Arc::new(AtomicU64::new(1)),
};
let app = Router::new()
.route("/ws", any(ws_handler))
.route("/count", get(count))
.with_state(state);
let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
.await
.unwrap();
println!("Listening on http://127.0.0.1:3000");
axum::serve(listener, app).await.unwrap();
}
Three ideas in this version deserve attention.
The map now stores a channel sender per client instead of an empty value. The sender half of each connection is fed by its own channel, exactly as the previous page showed. Broadcasting means sending the same message into every client's channel. The sender task for each connection drains its channel and writes to its socket. No task ever writes to another connection's socket directly.
The broadcast function collects dead clients instead of removing them while iterating. Removing entries from a map while looping over it is a classic source of bugs, and DashMap iteration plus removal in the same loop is no exception. The function records the ids whose channel send failed, finishes the loop, and then removes those ids. A failed channel send means the receiving end is gone, which means the connection's sender task ended, which means the client is gone. Broadcast becomes a second cleanup path, catching entries the main cleanup missed.
The goodbye broadcast runs after the removal, not before. The departing client is removed first, so it does not receive its own goodbye, and the count in the message is already correct when the others read it. Order matters here: announce after removing, and the message tells the truth.
Two Variations on the Shared Set
A standard map behind a Mutex
DashMap is convenient, but it is not the only way to share a set. The standard library version uses a HashSet behind a Mutex, a lock that lets one task use the set at a time. This version was compile-checked against the same dependency versions.
use std::collections::HashSet;
use std::sync::{Arc, Mutex};
#[derive(Clone)]
struct AppState {
clients: Arc<Mutex<HashSet<u64>>>,
next_id: Arc<AtomicU64>,
}
Inserting and removing look like this:
state.clients.lock().unwrap().insert(id);
state.clients.lock().unwrap().remove(&id);
And the count route reads the length the same way:
async fn count(State(state): State<AppState>) -> String {
state.clients.lock().unwrap().len().to_string()
}
The lock().unwrap() call takes the lock and panics if the lock is poisoned, which happens when another task panicked while holding it. For a small server this is acceptable, and it is the shape most beginners meet first. The trade-off against DashMap is contention: every insert, remove, and read takes the same single lock, so a burst of connections queue up behind each other. DashMap spreads that work across many small locks. For a handful of clients the difference is invisible. For thousands of clients connecting at once, it starts to matter. Choose the Mutex version when the code is small and the load is light. Choose DashMap when many tasks touch the set at the same time.
Storing the whole sender task handle
Some servers store more than a channel sender per client. They store the JoinHandle of the sender task, or a small struct with the id, a name, and the channel. The shape is the same: insert on connect, remove after the loop, and treat the map as the live picture of the room. The value type changes with what the application needs to do with a client. The cleanup discipline does not change. Whatever is stored, it is inserted in the handler and removed after the loop, in exactly one place each.
Cleanup as a Diagram
The lifecycle of one client, from the server's point of view, is a short path with cleanup at the end.
Client connects
|
v
handler takes an id, inserts it into the map
|
v
on_upgrade starts the socket task
|
v
receive loop runs (messages arrive)
|
v
loop ends: close frame, error, or None
|
v
remove the id from the map
|
v
abort the sender task (if the socket was split)
|
v
server state is exactly as before this client
The last line is the test for the whole page. If any step after the loop is missing, the server is not back to where it started, and the difference accumulates with every client.
Testing Disconnect Cleanup
A test for cleanup needs three steps: connect, check the count is one, disconnect, and check the count is zero. The test below runs the same server as the smallest example on a port the operating system picks, connects with tokio-tungstenite, and reads the count through the plain /count route with a raw HTTP request.
# Cargo.toml
[dev-dependencies]
tokio-tungstenite = "0.28"
futures-util = "0.3"
// tests/disconnect_test.rs
use axum::{
extract::{
ws::{Message, WebSocket, WebSocketUpgrade},
State,
},
response::Response,
routing::{any, get},
Router,
};
use dashmap::DashMap;
use futures_util::{SinkExt, StreamExt};
use std::sync::{
atomic::{AtomicU64, Ordering},
Arc,
};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio_tungstenite::connect_async;
#[derive(Clone)]
struct AppState {
clients: Arc<DashMap<u64, ()>>,
next_id: Arc<AtomicU64>,
}
async fn ws_handler(ws: WebSocketUpgrade, State(state): State<AppState>) -> Response {
let id = state.next_id.fetch_add(1, Ordering::Relaxed);
state.clients.insert(id, ());
ws.on_upgrade(move |socket| handle_socket(socket, state, id))
}
async fn handle_socket(mut socket: WebSocket, state: AppState, id: u64) {
while let Some(msg) = socket.recv().await {
match msg {
Ok(Message::Close(_)) => break,
Ok(_) => {}
Err(_) => break,
}
}
state.clients.remove(&id);
}
async fn count(State(state): State<AppState>) -> String {
state.clients.len().to_string()
}
async fn get_count(addr: std::net::SocketAddr) -> String {
let mut stream = tokio::net::TcpStream::connect(addr).await.unwrap();
stream
.write_all(b"GET /count HTTP/1.1\r\nHost: x\r\nConnection: close\r\n\r\n")
.await
.unwrap();
let mut buf = Vec::new();
stream.read_to_end(&mut buf).await.unwrap();
let text = String::from_utf8_lossy(&buf).into_owned();
text.split("\r\n\r\n").nth(1).unwrap_or("?").trim().to_string()
}
#[tokio::test]
async fn disconnect_removes_the_client() {
let state = AppState {
clients: Arc::new(DashMap::new()),
next_id: Arc::new(AtomicU64::new(1)),
};
let app = Router::new()
.route("/ws", any(ws_handler))
.route("/count", get(count))
.with_state(state);
let listener = tokio::net::TcpListener::bind("127.0.0.1:0")
.await
.unwrap();
let addr = listener.local_addr().unwrap();
tokio::spawn(async move {
axum::serve(listener, app).await.unwrap();
});
let url = format!("ws://{addr}/ws");
let (ws, _) = connect_async(&url).await.unwrap();
let (mut write, read) = ws.split();
tokio::time::sleep(std::time::Duration::from_millis(200)).await;
assert_eq!(get_count(addr).await, "1");
write.close().await.unwrap();
drop(read);
drop(write);
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
assert_eq!(get_count(addr).await, "0");
}
The two sleeps are doing real work. The first gives the server time to run the handler and insert the client before the count is read. The second gives the server time to notice the disconnect and run the removal before the count is read again. Without those pauses the test would race the server and fail for timing reasons rather than logic reasons. The half-second pause after disconnect is generous on purpose: it is long enough for the server to finish cleanup on any machine, and short enough that the test stays fast. This test follows the same pattern as the live run on this page, where the count went from 1 to 0.
Common Beginner Mistakes
Inserting inside the socket function instead of the handler
// Wrong - a gap where the client is connected but not counted
async fn ws_handler(ws: WebSocketUpgrade) -> Response {
ws.on_upgrade(handle_socket)
}
async fn handle_socket(mut socket: WebSocket, state: AppState, id: u64) {
state.clients.insert(id, ());
// ...
}
The socket function runs in a task Axum spawns after the 101 response. Between the response and the task starting, the client is connected and uncounted. Insert in the handler, before on_upgrade, so the client is counted from the moment the handshake succeeds.
Removing in one branch and forgetting the others
// Wrong - an error exit skips the removal
while let Some(msg) = socket.recv().await {
match msg {
Ok(Message::Close(_)) => {
state.clients.remove(&id);
break;
}
Ok(_) => {}
Err(_) => break,
}
}
The error branch breaks without removing. Every new exit path added to the loop is another chance to forget. Put the removal after the loop, once, where every path reaches it.
Holding the map lock across an await
// Wrong - the lock is held while waiting for a send
let clients = state.clients.lock().unwrap();
clients.get(&id).unwrap().send(message).await;
With the Mutex version, holding the lock across an await blocks every other task that wants the set for as long as the send takes. Clone what is needed out of the lock, drop the lock, and then await. With DashMap the same idea applies in a smaller way: clone the channel sender out of the entry and send after the borrow ends. The rule is short: never await while holding a lock on shared state.
Forgetting the sender task when the socket was split
// Wrong - the sender task keeps its half of a dead connection
state.clients.remove(&id);
Removing the client from the map does not stop the sender task that owns the sender half. That task keeps running, holding memory and trying to send. The cleanup after the loop must do both jobs: remove the entry and abort the sender task. The split page showed the abort, and this page adds the removal. A connection is only fully cleaned up when both happen.
Cleanup Has Two Halves:
Removing the map entry and stopping the sender task are separate jobs, and both are required. A server that removes the entry but forgets the task leaks a task per client. A server that stops the task but forgets the entry leaks a map entry per client. Check for both when a connection ends.
Final Complete Example
Here is everything from this page in one place: the shared set, insertion in the handler, removal after the loop, and the count route that makes the whole thing observable.
// src/main.rs
use axum::{
extract::{
ws::{Message, WebSocket, WebSocketUpgrade},
State,
},
response::Response,
routing::{any, get},
Router,
};
use dashmap::DashMap;
use std::sync::{
atomic::{AtomicU64, Ordering},
Arc,
};
#[derive(Clone)]
struct AppState {
clients: Arc<DashMap<u64, ()>>,
next_id: Arc<AtomicU64>,
}
async fn ws_handler(ws: WebSocketUpgrade, State(state): State<AppState>) -> Response {
let id = state.next_id.fetch_add(1, Ordering::Relaxed);
state.clients.insert(id, ());
println!("client {id} connected, total now {}", state.clients.len());
ws.on_upgrade(move |socket| handle_socket(socket, state, id))
}
async fn handle_socket(mut socket: WebSocket, state: AppState, id: u64) {
while let Some(msg) = socket.recv().await {
match msg {
Ok(Message::Text(text)) => {
println!("client {id} says: {text}");
}
Ok(Message::Close(_)) => break,
Ok(_) => {}
Err(_) => break,
}
}
state.clients.remove(&id);
println!("client {id} removed, total now {}", state.clients.len());
}
async fn count(State(state): State<AppState>) -> String {
state.clients.len().to_string()
}
#[tokio::main]
async fn main() {
let state = AppState {
clients: Arc::new(DashMap::new()),
next_id: Arc::new(AtomicU64::new(1)),
};
let app = Router::new()
.route("/ws", any(ws_handler))
.route("/count", get(count))
.with_state(state);
let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
.await
.unwrap();
println!("Listening on http://127.0.0.1:3000");
axum::serve(listener, app).await.unwrap();
}
Run the server and the client from the first section. The count goes 1 and then 0, and the server log shows the insert and the removal. That round trip is the behaviour to protect: every connection that is counted in must be counted out, on every way the connection can end.
Summary
Disconnect cleanup is a discipline, not a feature. The server notices a disconnect only by trying to use the connection and finding it gone, so the receive loop ending is the signal, and the line after the loop is the cleanup point. Insert in the handler so the client is counted from the handshake. Remove after the loop so every exit path cleans up. Abort the sender task so no task outlives its connection. And make the state observable, with a count route or a log line, so a leak shows up as a number that never returns to zero.
The deeper point is about what a connection set really is. It is not a list of everyone who ever connected. It is a live picture of who is connected right now, and a picture is only useful if it is kept current. The next page is about the clients that never disconnect at all: the ones that go silent, and how a timer and a ping can tell a quiet client from a dead one.