From 3582de06546917f2cc72580cacf69e5c5970dcff Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 15 Jan 2015 14:42:08 +0100 Subject: [PATCH] Fix initializing clientHandledStanzasCount MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From XEP-198: Stream Management ยง 4. Acks: """ Note: There are two values of 'h' for any given stream: one maintained by the client to keep track of stanzas it has handled from the server, and one maintained by the server to keep track of stanzas it has handled from the client. The client initializes its value to zero when it sends to the server, and the server initializes its value to zero when it sends to the client (it is expected that the server will respond immediately to and set its counter to zero at that time). """ Previously smack initialized both to 0 just before sending enabled. But according to the note from XEP-198 the server's counter is initialized by the server "when it sends to the client, so we need to set clientHandledStanzasCount to 0 when we receive . Because the server started counted right after he send . Thanks to Kim "zash" Alvefur for pointing this out. --- .../main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index 3b68ed20c..2a2ec2cfa 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -362,7 +362,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { if (isSmAvailable() && useSm) { // Remove what is maybe left from previously stream managed sessions unacknowledgedStanzas = new ArrayBlockingQueue(QUEUE_SIZE); - clientHandledStanzasCount = 0; serverHandledStanzasCount = 0; // XEP-198 3. Enabling Stream Management. If the server response to 'Enable' is 'Failed' // then this is a non recoverable error and we therefore throw an exception. @@ -1047,6 +1046,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { // Mark this a aon-resumable stream by setting smSessionId to null smSessionId = null; } + clientHandledStanzasCount = 0; smWasEnabledAtLeastOnce = true; smEnabledSyncPoint.reportSuccess(); LOGGER.fine("Stream Management (XEP-198): succesfully enabled");