From f982885d2efa15311cdd735b5c9b3d8492ec4680 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 22 Jan 2023 16:13:16 +0100 Subject: [PATCH] fix regression in ping strategy --- .../java/im/conversations/android/xmpp/ConnectionPool.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/im/conversations/android/xmpp/ConnectionPool.java b/src/main/java/im/conversations/android/xmpp/ConnectionPool.java index fba51e0e9..cf218e6ab 100644 --- a/src/main/java/im/conversations/android/xmpp/ConnectionPool.java +++ b/src/main/java/im/conversations/android/xmpp/ConnectionPool.java @@ -267,7 +267,7 @@ public class ConnectionPool { final long lastReceived = connection.getLastPacketReceived(); final long lastSent = connection.getLastPingSent(); final long msToNextPing = - (Math.max(lastReceived, lastSent) + Config.PING_MAX_INTERVAL) + (Math.max(lastReceived, lastSent) + Config.PING_MAX_INTERVAL * 1000) - SystemClock.elapsedRealtime(); final int pingTimeout = lowPingTimeoutMode.contains(account.address) @@ -280,8 +280,7 @@ public class ConnectionPool { Log.d(Config.LOGTAG, account.address + ": ping timeout"); this.reconnectAccount(connection); } else { - final int secs = (int) (pingTimeoutIn / 1000); - this.scheduleWakeUpCall(secs); + this.scheduleWakeUpCall(Ints.saturatedCast(pingTimeoutIn / 1000)); } } else { pingCandidates.add(connection);