Skip to content

Commit

Permalink
fix: v5 doesn't write outgoing packets onto network (#842)
Browse files Browse the repository at this point in the history
* fix: v5 doesn't write outgoing packets onto network

#825 (comment)

* same for pingreq
  • Loading branch information
Devdutt Shenoi authored Apr 7, 2024
1 parent af55848 commit d4c30df
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions rumqttc/src/v5/eventloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand All @@ -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())
}
Expand Down

0 comments on commit d4c30df

Please sign in to comment.