From b7cc3d4645a896e3fa078657db34e92012552b1a Mon Sep 17 00:00:00 2001 From: Kai Jewson Date: Sun, 12 Dec 2021 14:08:00 +0000 Subject: [PATCH] Clarify that servers shouldn't implement Websocket ping/pong (#617) --- axum/src/extract/ws.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/axum/src/extract/ws.rs b/axum/src/extract/ws.rs index 74f2e86e..0f371e79 100644 --- a/axum/src/extract/ws.rs +++ b/axum/src/extract/ws.rs @@ -466,11 +466,18 @@ pub enum Message { Binary(Vec), /// A ping message with the specified payload /// - /// The payload here must have a length less than 125 bytes + /// The payload here must have a length less than 125 bytes. + /// + /// Ping messages will be automatically responded to by the server, so you do not have to worry + /// about dealing with them yourself. Ping(Vec), /// A pong message with the specified payload /// - /// The payload here must have a length less than 125 bytes + /// The payload here must have a length less than 125 bytes. + /// + /// Pong messages will be automatically sent to the client if a ping message is received, so + /// you do not have to worry about constructing them yourself unless you want to implement a + /// [unidirectional heartbeat](https://tools.ietf.org/html/rfc6455#section-5.5.3). Pong(Vec), /// A close message with the optional close frame. Close(Option>),