Registry / networking / tokio-tungstenite

tokio-tungstenite

JSON →
library0.29.0rscratesunverified

Tokio binding for Tungstenite, the Lightweight stream-based WebSocket implementation

# Cargo.toml [dependencies] tokio-tungstenite = "0.29.0"
INSTALL
IMPORT
SIG · TOKIO-TUNGSTENITE
T
tokio-tungstenite
networkingrustv0.29.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

connect_async
use tokio_tungstenite::connect_async;

Connect to a WebSocket server and send/receive messages.

use tokio_tungstenite::connect_async; use tokio_tungstenite::tungstenite::Message; #[tokio::main] async fn main() { let (mut ws_stream, _) = connect_async("wss://echo.websocket.org").await.unwrap(); ws_stream.send(Message::Text("Hello".into())).await.unwrap(); let msg = ws_stream.next().await.unwrap().unwrap(); println!("Received: {}", msg); }
Debug
Known issues
gotchaRequires a Tokio runtime to execute async functions.
fix
Use #[tokio::main] or manually create a runtime.
affects: *
Upgrade
Version history
0.29.0latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
33 hits · last 30 days
node
28
Resources
tokio-tungstenite — cargo add tokio-tungstenite · libregistry