ockam icon indicating copy to clipboard operation
ockam copied to clipboard

refactor(rust): disable heartbeats in tcp server side

Open michealkeines opened this issue 2 years ago • 0 comments

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

image

image

initiator was able to schedule heartbeats, responder was not able to schedule

Checks

michealkeines avatar Sep 17 '22 17:09 michealkeines