diff --git a/tokio-xmpp/ChangeLog b/tokio-xmpp/ChangeLog
index b870cbae..26fb27f8 100644
--- a/tokio-xmpp/ChangeLog
+++ b/tokio-xmpp/ChangeLog
@@ -8,6 +8,8 @@ Version NEXT:
- Gate `AsRawFd` behind `ktls` feature to make Windows build work again.
- Implicitly use the `Client`'s bound JID on empty `to` in tokio-xmpp's
`IqResponseTracker`.
+ - Actually count inbound stream management stanzas (!657) instead of
+ always sending h='0' in our ``.
Version 5.0.0:
2025-10-28 pep
diff --git a/tokio-xmpp/src/event.rs b/tokio-xmpp/src/event.rs
index 857178b7..347374f4 100644
--- a/tokio-xmpp/src/event.rs
+++ b/tokio-xmpp/src/event.rs
@@ -21,6 +21,9 @@ pub(crate) fn make_id() -> String {
}
/// A stanza sent/received over the stream.
+// WARNING: do not add variants to this enum! Adding variants which refer
+// to anything but IQ, Message or Presence stanzas will cause the
+// stream management counters to be off.
#[derive(FromXml, AsXml, Debug, PartialEq)]
#[xml()]
pub enum Stanza {
diff --git a/tokio-xmpp/src/stanzastream/connected.rs b/tokio-xmpp/src/stanzastream/connected.rs
index 47512b0c..6155b500 100644
--- a/tokio-xmpp/src/stanzastream/connected.rs
+++ b/tokio-xmpp/src/stanzastream/connected.rs
@@ -543,6 +543,9 @@ impl ConnectedState {
match item {
// Easy case, we got some data.
Ok(XmppStreamElement::Stanza(data)) => {
+ if let Some(sm_state) = sm_state.as_mut() {
+ sm_state.received();
+ }
Poll::Ready(Some(ConnectedEvent::Worker(WorkerEvent::Stanza(data))))
}
diff --git a/tokio-xmpp/src/stanzastream/stream_management.rs b/tokio-xmpp/src/stanzastream/stream_management.rs
index bb60d126..9ca601bf 100644
--- a/tokio-xmpp/src/stanzastream/stream_management.rs
+++ b/tokio-xmpp/src/stanzastream/stream_management.rs
@@ -214,6 +214,11 @@ impl SmState {
self.inbound_ctr
}
+ /// Increase the inbound counter.
+ pub fn received(&mut self) {
+ self.inbound_ctr = self.inbound_ctr.wrapping_add(1);
+ }
+
/// Get the info necessary for resumption.
///
/// Returns the stream ID and the current inbound counter if resumption is