Skip to content

Commit

Permalink
Merge pull request eqlabs#1915 from eqlabs/sistemd/websocket-ping-and…
Browse files Browse the repository at this point in the history
…-close

feat(ws): make sure pings, pongs, and close messages are handled correctly
  • Loading branch information
sistemd authored Apr 1, 2024
2 parents 03f8a58 + 5da19c3 commit 1408fe7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/rpc/src/jsonrpc/websocket/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,16 @@ async fn read(
let request = match receiver.next().await {
Some(Ok(Message::Text(x))) => x.into_bytes(),
Some(Ok(Message::Binary(x))) => x,
Some(Ok(Message::Ping(_)))
| Some(Ok(Message::Pong(_)))
| Some(Ok(Message::Close(_))) => continue,
// Both of these are client disconnects according to the axum example
// https://docs.rs/axum/0.6.20/axum/extract/ws/index.html#example
Some(Ok(Message::Ping(_))) | Some(Ok(Message::Pong(_))) => {
// Ping and pong messages are handled automatically by axum.
continue;
}
// All of the following indicate client disconnection.
Some(Err(e)) => {
tracing::trace!(error=%e, "Client disconnected");
break;
}
None => {
Some(Ok(Message::Close(_))) | None => {
tracing::trace!("Client disconnected");
break;
}
Expand Down

0 comments on commit 1408fe7

Please sign in to comment.