From d4c30df8344247d271c36f31d5faad5b2b291053 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Sun, 7 Apr 2024 23:28:12 +0530 Subject: [PATCH] fix: v5 doesn't write outgoing packets onto network (#842) * fix: v5 doesn't write outgoing packets onto network https://github.com/bytebeamio/rumqtt/pull/825#issuecomment-2041392647 * same for pingreq --- rumqttc/src/v5/eventloop.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rumqttc/src/v5/eventloop.rs b/rumqttc/src/v5/eventloop.rs index ab1edb17c..a59094807 100644 --- a/rumqttc/src/v5/eventloop.rs +++ b/rumqttc/src/v5/eventloop.rs @@ -209,7 +209,9 @@ impl EventLoop { self.options.pending_throttle ), if !self.pending.is_empty() || (!inflight_full && !collision) => match o { Ok(request) => { - self.state.handle_outgoing_packet(request)?; + if let Some(outgoing) = self.state.handle_outgoing_packet(request)? { + network.write(outgoing).await?; + } network.flush().await?; Ok(self.state.events.pop_front().unwrap()) } @@ -228,7 +230,9 @@ impl EventLoop { let timeout = self.keepalive_timeout.as_mut().unwrap(); timeout.as_mut().reset(Instant::now() + self.options.keep_alive); - self.state.handle_outgoing_packet(Request::PingReq)?; + if let Some(outgoing) = self.state.handle_outgoing_packet(Request::PingReq)? { + network.write(outgoing).await?; + } network.flush().await?; Ok(self.state.events.pop_front().unwrap()) }