increased reconnection interval after policy violation
This commit is contained in:
parent
9ea4f1534b
commit
d3ccba445a
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue