ockam
ockam copied to clipboard
refactor(rust): disable heartbeats in tcp server side
Added
as per #3480 suggested solution
I tested this with a simple example and some debug print messages, and schedule_heartbeat
was only called in the client side
self.heartbeat_interval = Some(Duration::from_secs(5));
// Check if the connection is initiated by us
if self.is_initiator {
println!("Scheduling {:?}", self.peer);
self.schedule_heartbeat().await?;
} else {
println!("Else {:?}", self.peer);
}
OUTPUT
cargo run --example 04-routing-over-transport-responder
struct Alice;
#[ockam::worker]
impl Worker for Alice {
type Context = Context;
type Message = String;
async fn handle_message(&mut self, ctx: &mut Context, msg: Routed<String>) -> Result<()> {
println!("Alice is gonna handle this message: {:?}", msg.as_body());
use tokio::time::{sleep, Duration};
sleep(Duration::from_secs(10)).await;
println!("Alice is gonna respond");
ctx.send(msg.return_route(), msg.body()).await?;
Ok(())
}
}
cargo run --example 04-routing-over-transport-initiator
initiator was able to schedule heartbeats, responder was not able to schedule
Checks
- [x] All commits in this Pull Request are signed and Verified by Github.
- [x] All commits in this Pull Request follow the Ockam commit message convention.
- [x] I accept the Ockam Community Code of Conduct.
- [x] I have accepted the Ockam Contributor License Agreement by adding my Git/Github details in a row at the end of the CONTRIBUTORS.csv file in a separate pull request to the build-trust/ockam-contributors repository.