Can you show your attempt that doesn't compile? I don't know how exactly you're trying to handle the timeout, but I would just do something like replacing the panic!() with return Err(/* something denoting a timeout */);.
/*
* TODO: Fix panic with better error handling
*/
Err(e) => {
error!("in Elapsed: timeout while connecting to server : {:?}", e);
//panic!("{}", format!("timeout while connecting to server : {}", e))
return Err(e.into())
}
Which works for that block but then the outbound isn't anymore a TcpStream.
The question is, is there a recoverable error with TcpStream when a timeout occur?
That's the compiler errors.
RUST_LOG=info ENCODED_PW=My-Enc_PW TPT_CONFIG=container-files/etc/tpt/config.yaml cargo run
Compiling tls-proxy-tunnel v3.0.0 (/datadisk/git-repos/tls-proxy-tunnel)
error[E0599]: no method named `peer_addr` found for unit type `()` in the current scope
--> src/upstreams/proxy_to_upstream.rs:92:46
|
92 | debug!("Connected to {:?}", outbound.peer_addr().unwrap());
| ^^^^^^^^^ method not found in `()`
error[E0599]: no method named `set_nodelay` found for unit type `()` in the current scope
--> src/upstreams/proxy_to_upstream.rs:94:18
|
94 | outbound.set_nodelay(true)?;
| ^^^^^^^^^^^ method not found in `()`
error[E0599]: no method named `writable` found for unit type `()` in the current scope
--> src/upstreams/proxy_to_upstream.rs:103:22
|
103 | outbound.writable().await?;
| ^^^^^^^^ method not found in `()`