use reqwest_impersonate as reqwest; use std::error::Error; use tungstenite::Message; use futures_util::{SinkExt, StreamExt, TryStreamExt}; use reqwest::{impersonate::Impersonate, Client}; #[tokio::main] async fn main() -> Result<(), Box> { let websocket = Client::builder() .impersonate_websocket(Impersonate::Chrome120) .build()? .get("wss://echo.websocket.org") .upgrade() .send() .await? .into_websocket() .await?; let (mut tx, mut rx) = websocket.split(); tokio::spawn(async move { for i in 1..11 { tx.send(Message::Text(format!("Hello, World! #{i}"))) .await .unwrap(); } }); while let Some(message) = rx.try_next().await? { match message { Message::Text(text) => println!("received: {text}"), _ => {} } } Ok(()) }