Hello.
I'm have a problem with TCP Server (tokio::net::TcpListener - Rust).
Server send packet with RST,ACK flag to tcp client - periodic ~120 sec. And establishes a new session.
Why is this happening? Can I set it up somehow?
let done = listener.incoming().map_err(
move |e| { /* log error */}).for_each(move |socket| {
socket.set_nodelay(true).expect("Cannot set no delay option.");
let dur = Duration::from_secs(300);
socket.set_keepalive(Some(dur)).expect("Cannot set keepalive option.");
socket.set_linger(Some(dur)).expect("Cannot set keepalive option.");
socket.set_ttl(250).expect("set_ttl failed");
let processor = tcp_reader.for_each(
move |bytes|{
/* Process */
}).and_then(move |()| {
Ok(())
}).or_else(move |err| {
Err(err)
}).then(move |result| {
Ok(())
});
tokio::spawn(processor)
});
If you are leaving a connection open and idle for a long time, has the client been configured to send keepalive packets (tokio::net::TcpStream::set_keepalive())?
A TcpStream is an abstraction over TCP that provides you with a stream of bytes, so it tries to hide things like the existence of TCP packets and headers. Most TcpStream types will deliberately only expose functions for reading/writing data, and maybe a couple simple knobs like timeouts or keep-alives.
If you want access to the TCP headers then you'd need to use a different TCP library. Maybe something that lets you work with raw sockets from the OS and gives you fine-grained access like pnet.