ockam
ockam copied to clipboard
Disable Ockam Heartbeats for Tcp on server side
While we don't support TCP-level keep-alive #3450, we occassionally send empty Ockam packets in tcp workers to:
- Keep connection alive
- Find out early if connection was closed We call that Heartbeat. Thos packets are sent here and they're just ignored while receiving here.
The idea is that only client side (the side that initiates connection) should do that, while currently rust doesn't check that and always sends them. Possible solution is to store information about connection role (client or server) in TcpSendWorker
and enable/disable heartbeats based on that
Hi @SanjoDeundiak, can i work on this issue?
@michealkeines of course, all yours.
I checked the TcpSendWorker
struct
I have tried your solution, we can add is_initiator
and call schedule_heartbeat()
based on this value
pub(crate) struct TcpSendWorker {
...
is_initiator: bool,
}
if self.is_initiator {
self.schedule_heartbeat().await?;
}
TCP send worker pair could be created using TcpSendWorker::new_pair
, we can update these two calls
//listener.rs:60 - we dont want listeners to start heartbeats as they act as server
TcpSendWorker::new_pair(ctx, handle_clone, Some(stream), peer, Vec::new(), false).await?;
//sender.rs:138 - we want any send call to start heartbeats
Self::new_pair(ctx, router_handle, stream, peer, hostnames, true).await?;
Please correct me, if i have missed something. @mrinalwadhwa @SanjoDeundiak
@michealkeines sounds great!
@michealkeines hold on, we may have race condition with #3492
@michealkeines I think this issue is superseded by #3492
@michealkeines Thank you for spending time on this!