From c2f7b6ed92622cc19e3f2ca086038bd0a7266924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Wed, 18 Oct 2023 23:11:06 +0200 Subject: [PATCH] ws: upgrade tungstenite --- Cargo.lock | 8 ++++---- aquatic_ws/Cargo.toml | 4 ++-- aquatic_ws/src/config.rs | 2 ++ aquatic_ws/src/workers/socket.rs | 3 ++- aquatic_ws_load_test/Cargo.toml | 4 ++-- aquatic_ws_protocol/Cargo.toml | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8d52d58..bd2a63c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -396,9 +396,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-tungstenite" -version = "0.22.2" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce01ac37fdc85f10a43c43bc582cbd566720357011578a935761075f898baf58" +checksum = "a1e9efbe14612da0a19fb983059a0b621e9cf6225d7018ecab4f9988215540dc" dependencies = [ "futures-io", "futures-util", @@ -2743,9 +2743,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "tungstenite" -version = "0.19.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15fba1a6d6bb030745759a9a2a588bfe8490fc8b4751a277db3a0be1c9ebbf67" +checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" dependencies = [ "byteorder", "bytes", diff --git a/aquatic_ws/Cargo.toml b/aquatic_ws/Cargo.toml index 598cb1f..3f899d4 100644 --- a/aquatic_ws/Cargo.toml +++ b/aquatic_ws/Cargo.toml @@ -28,7 +28,7 @@ aquatic_toml_config.workspace = true aquatic_ws_protocol.workspace = true anyhow = "1" -async-tungstenite = "0.22" +async-tungstenite = "0.23" cfg-if = "1" futures = "0.3" futures-lite = "1" @@ -49,7 +49,7 @@ serde = { version = "1", features = ["derive"] } signal-hook = { version = "0.3" } slab = "0.4" socket2 = { version = "0.5", features = ["all"] } -tungstenite = "0.19" +tungstenite = "0.20" [dev-dependencies] quickcheck = "1" diff --git a/aquatic_ws/src/config.rs b/aquatic_ws/src/config.rs index 25651e1..16903a2 100644 --- a/aquatic_ws/src/config.rs +++ b/aquatic_ws/src/config.rs @@ -76,6 +76,7 @@ pub struct NetworkConfig { pub websocket_max_message_size: usize, pub websocket_max_frame_size: usize, + pub websocket_write_buffer_size: usize, /// Return a HTTP 200 Ok response when receiving GET /health. Can not be /// combined with enable_tls. @@ -95,6 +96,7 @@ impl Default for NetworkConfig { websocket_max_message_size: 64 * 1024, websocket_max_frame_size: 16 * 1024, + websocket_write_buffer_size: 8 * 1024, enable_http_health_checks: false, } diff --git a/aquatic_ws/src/workers/socket.rs b/aquatic_ws/src/workers/socket.rs index 09c1884..58bfaa3 100644 --- a/aquatic_ws/src/workers/socket.rs +++ b/aquatic_ws/src/workers/socket.rs @@ -464,7 +464,8 @@ async fn run_stream_agnostic_connection< let ws_config = tungstenite::protocol::WebSocketConfig { max_frame_size: Some(config.network.websocket_max_frame_size), max_message_size: Some(config.network.websocket_max_message_size), - max_send_queue: Some(2), + write_buffer_size: config.network.websocket_write_buffer_size, + max_write_buffer_size: config.network.websocket_write_buffer_size * 3, ..Default::default() }; let stream = async_tungstenite::accept_async_with_config(stream, Some(ws_config)).await?; diff --git a/aquatic_ws_load_test/Cargo.toml b/aquatic_ws_load_test/Cargo.toml index e5c26d2..2ad2a72 100644 --- a/aquatic_ws_load_test/Cargo.toml +++ b/aquatic_ws_load_test/Cargo.toml @@ -19,7 +19,7 @@ aquatic_toml_config.workspace = true aquatic_ws_protocol.workspace = true anyhow = "1" -async-tungstenite = "0.22" +async-tungstenite = "0.23" futures = "0.3" futures-rustls = "0.24" glommio = "0.8" @@ -30,7 +30,7 @@ rand_distr = "0.4" rustls = { version = "0.21", default-features = false, features = ["dangerous_configuration"] } serde = { version = "1", features = ["derive"] } serde_json = "1" -tungstenite = "0.19" +tungstenite = "0.20" [dev-dependencies] quickcheck = "1" diff --git a/aquatic_ws_protocol/Cargo.toml b/aquatic_ws_protocol/Cargo.toml index ba89914..9a44235 100644 --- a/aquatic_ws_protocol/Cargo.toml +++ b/aquatic_ws_protocol/Cargo.toml @@ -25,7 +25,7 @@ hashbrown = { version = "0.14", features = ["serde"] } serde = { version = "1", features = ["derive"] } serde_json = "1" simd-json = { version = "0.10", features = ["allow-non-simd"] } -tungstenite = "0.19" +tungstenite = "0.20" [dev-dependencies] criterion = "0.5"