From bcfe7b12a4b50fb1a482d92f72d47ae14c6eb007 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 20 Jul 2020 14:23:09 +0200 Subject: [PATCH] [tcp] Mark SM as disabled prior resource binding Otherwise we may send a SM ack request with the bind IQ request, causing a stream error: D/SMACK: SENT (0): D/SMACK: RECV (0): snakeman@wiuwiu.de/eHeTGlCq --- .../java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 6 +++++- 1 file changed, 5 insertions(+), 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 ad86ce420..52ed8a077 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 @@ -407,6 +407,11 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { LOGGER.fine("Stream resumption failed, continuing with normal stream establishment process: " + smResumptionFailed); } + // We either failed to resume a previous stream management (SM) session, or we did not even try. In any case, + // mark SM as not enabled. Most importantly, we do this prior calling bindResourceAndEstablishSession(), as the + // bind IQ may trigger a SM ack request, which would be invalid in the pre resource bound state. + smEnabledSyncPoint = false; + List previouslyUnackedStanzas = new LinkedList(); if (unacknowledgedStanzas != null) { // There was a previous connection with SM enabled but that was either not resumable or @@ -425,7 +430,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { // unacknowledgedStanzas and become duplicated on reconnect. See SMACK-706. bindResourceAndEstablishSession(resource); - smEnabledSyncPoint = false; if (isSmAvailable() && useSm) { // Remove what is maybe left from previously stream managed sessions serverHandledStanzasCount = 0;