I am upgrading tokio-tungstenite from 0.9 to 0.10, which no longer has the peer_addr
method. I am dealing with WebSocketStream
. I have tried this, which would have worked before:
use tokio_tungstenite::connect_async;
fn main() {
async fn test() {
println!("Hello, world!");
let url = "wss://echo.websocket.org".to_string();
let (ws_stream, ws_response) = connect_async(url).await.unwrap();
let addr = ws_stream.peer_addr();
println!("peer addr {:?}", addr);
}
}
peer_addr()
no longer exists and I can see no replacement or instructions on what to do now. I've tried searching the documentation and GitHub.
Cargo.toml:
futures = { version = "0.3" }
tungstenite = {version="0.11.0", features=["tls"] }
tokio-tungstenite = { version="0.10.1", features = ["tls"] }
tokio = {version ="0.2.21", features = [ "full" ] }
url = "2.0"