TLS handshake eof in async-std-echo.rs example when forcing WSS
sedrik opened this issue · 2 comments
sedrik commented
I don't get a valid WSS connection when trying the example. Not sure if I am doing something wrong.
Error: Io(Custom { kind: UnexpectedEof, error: "tls handshake eof" })
This is my Cargo.toml
[package]
name = "async_maker"
version = "0.1.0"
authors = ["Fredrik Park <sir.sedrik@gmail.com>"]
edition = "2018"
[dependencies]
async-std = "1.6.3"
futures = "0.3"
async-tungstenite = { version = "0.8", default-features = false, features = ["async-tls", "async-std-runtime"] }
For completeness I am including the code that I use (it's the example with the ws:// url removed).
use async_tungstenite::async_std::connect_async;
use async_tungstenite::tungstenite::Message;
use futures::prelude::*;
use async_std::task;
async fn run() -> Result<(), Box<dyn std::error::Error>> {
let url = "wss://echo.websocket.org";
let (mut ws_stream, _) = connect_async(url).await?;
let text = "Hello, World!";
println!("Sending: \"{}\"", text);
ws_stream.send(Message::text(text)).await?;
let msg = ws_stream
.next()
.await
.ok_or_else(|| "didn't receive anything")??;
println!("Received: {:?}", msg);
Ok(())
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
task::block_on(run())
}
sedrik commented
cargo run --features="async-std-runtime, async-tls" --example async-std-echo
also reproduces the issue for me.
sdroege commented
That's async-tls
(and probably rustls
in general?) being incompatible with the TLS on echo.websocket.org
. If you use async-native-tls
(using your system's TLS stack on Windows/macOS/etc and OpenSSL on Linux/BSD/etc) instead of async-tls
it will work fine.