From d3ccba445af2425476f65b098d80338c5d2a2008 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 16 Aug 2019 15:00:26 +0200 Subject: [PATCH] increased reconnection interval after policy violation --- .../eu/siacs/conversations/http/HttpDownloadConnection.java | 1 - src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java index cc77a211c..8c366558d 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java @@ -22,7 +22,6 @@ import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.DownloadableFile; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Transferable; -import eu.siacs.conversations.entities.TransferablePlaceholder; import eu.siacs.conversations.persistance.FileBackend; import eu.siacs.conversations.services.AbstractConnectionManager; import eu.siacs.conversations.services.XmppConnectionService; diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 250a11d2d..23bb3cf6e 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -1329,6 +1329,7 @@ public class XmppConnection implements Runnable { } else if (streamError.hasChild("host-unknown")) { throw new StateChangingException(Account.State.HOST_UNKNOWN); } else if (streamError.hasChild("policy-violation")) { + this.lastConnect = SystemClock.elapsedRealtime(); final String text = streamError.findChildContent("text"); Log.d(Config.LOGTAG,account.getJid().asBareJid()+": policy violation. "+text); throw new StateChangingException(Account.State.POLICY_VIOLATION); @@ -1577,7 +1578,8 @@ public class XmppConnection implements Runnable { } public int getTimeToNextAttempt() { - final int interval = Math.min((int) (25 * Math.pow(1.3, attempt)), 300); + final int additionalTime = account.getLastErrorStatus() == Account.State.POLICY_VIOLATION ? 3 : 0; + final int interval = Math.min((int) (25 * Math.pow(1.3, (additionalTime + attempt))), 300); final int secondsSinceLast = (int) ((SystemClock.elapsedRealtime() - this.lastConnect) / 1000); return interval - secondsSinceLast; }