From 352e4225628eb895d1ec8f3d12b1e5124c03d7a5 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 3 Dec 2015 13:30:44 +0100 Subject: [PATCH] Drop SM state *before* binding the resource as otherwise and may be duplicated on reconnect. Fixes SMACK-706. --- .../org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 cd4e320c6..20d9e4495 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 @@ -399,8 +399,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { LOGGER.fine("Stream resumption failed, continuing with normal stream establishment process"); } - bindResourceAndEstablishSession(resource); - List previouslyUnackedStanzas = new LinkedList(); if (unacknowledgedStanzas != null) { // There was a previous connection with SM enabled but that was either not resumable or @@ -413,6 +411,12 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { // after the 'enable' stream element has been sent. dropSmState(); } + + // Now bind the resource. It is important to do this *after* we dropped an eventually + // existing Stream Management state. As otherwise and may end up in + // unacknowledgedStanzas and become duplicated on reconnect. See SMACK-706. + bindResourceAndEstablishSession(resource); + if (isSmAvailable() && useSm) { // Remove what is maybe left from previously stream managed sessions serverHandledStanzasCount = 0;