Getting error when trying to do non blocking `TcpStream` with TLS
lemonlambda opened this issue · 0 comments
lemonlambda commented
pub(crate) fn connect_to_gateway(mut commands: Commands, get_gateway: Res<GetGateway>) {
// Get the ip
info!("Gateway URL: {}", get_gateway.0);
let binding = Url::parse(&get_gateway.0).unwrap();
let host = binding.host().unwrap();
info!("Host: {host}");
let ip = format!("{}:443", host);
info!("IP: {ip}");
// Get the tls stream
let mut tcp = {
let mut stream = TcpStream::connect(ip.clone()).unwrap();
stream.set_nonblocking(true).unwrap();
stream
};
// Connect to the socket and insert into a resource
let socket = client_tls(&get_gateway.0, tcp).unwrap().0;
commands.insert_resource(WebsocketStream(socket));
info!("Connected Succesfully to discord");
}
thread 'TaskPool (10)' panicked at src/events.rs:62:46:
called `Result::unwrap()` on an `Err` value: HandshakeError::Interrupted(...)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `strike::events::connect_to_gateway`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!
How would I do this?