https://github.com/user-attachments/assets/eb43ffec-ec7f-42e7-9738-b71631fee8d8
On the above video I use timeout less than 10s because I don’t want to make the video too long
0 seconds (we can force like min 10s but allowing min as 0 would give user more control over the timeout), also default is 1800 (30mins)31536000 seconds which is 1 year (check comments below)ghcr.io/shadowarcanist/coolify-dev:latest to test it locally.// main.rs
use std::net::TcpStream;
use std::time::{Duration, Instant};
use std::io::{Read};
use std::process::exit;
fn main() {
let addr = "192.168.1.222:5566"; // NGINX stream port
let probe_interval = Duration::from_secs(1);
println!("Connecting to {}", addr);
let mut stream = match TcpStream::connect(addr) {
Ok(s) => s,
Err(e) => {
eprintln!("Connection failed: {}", e);
exit(1);
}
};
// Make reads non-blocking so we don't hang forever
stream
.set_read_timeout(Some(Duration::from_secs(1)))
.expect("Failed to set read timeout");
let start = Instant::now();
let mut buf = [0u8; 1];
println!("Connected. Waiting for NGINX to close idle connection...");
loop {
match stream.read(&mut buf) {
Ok(0) => {
println!(
"Connection closed cleanly (EOF) after {:.2?}",
start.elapsed()
);
break;
}
Ok(_) => {
println!("Unexpected data received (connection active)");
}
Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock
|| e.kind() == std::io::ErrorKind::TimedOut =>
{
// Normal idle state
}
Err(e) => {
println!(
"Connection closed by peer after {:.2?}: {}",
start.elapsed(),
e
);
break;
}
}
std::thread::sleep(probe_interval);
}
println!("Test complete.");
}
ShadowArcanist
@ShadowArcanist
Zach Latta
@zachlatta