use more aggressive reconnect intervals during rtp session
This commit is contained in:
parent
fd4b8ba188
commit
8570c9f912
|
@ -466,14 +466,15 @@ public class XmppConnectionService extends Service {
|
||||||
} else if (account.getStatus() != Account.State.CONNECTING && account.getStatus() != Account.State.NO_INTERNET) {
|
} else if (account.getStatus() != Account.State.CONNECTING && account.getStatus() != Account.State.NO_INTERNET) {
|
||||||
resetSendingToWaiting(account);
|
resetSendingToWaiting(account);
|
||||||
if (connection != null && account.getStatus().isAttemptReconnect()) {
|
if (connection != null && account.getStatus().isAttemptReconnect()) {
|
||||||
final int next = connection.getTimeToNextAttempt();
|
final boolean aggressive = hasJingleRtpConnection(account);
|
||||||
|
final int next = connection.getTimeToNextAttempt(aggressive);
|
||||||
final boolean lowPingTimeoutMode = isInLowPingTimeoutMode(account);
|
final boolean lowPingTimeoutMode = isInLowPingTimeoutMode(account);
|
||||||
if (next <= 0) {
|
if (next <= 0) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": error connecting account. reconnecting now. lowPingTimeout=" + lowPingTimeoutMode);
|
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": error connecting account. reconnecting now. lowPingTimeout=" + lowPingTimeoutMode);
|
||||||
reconnectAccount(account, true, false);
|
reconnectAccount(account, true, false);
|
||||||
} else {
|
} else {
|
||||||
final int attempt = connection.getAttempt() + 1;
|
final int attempt = connection.getAttempt() + 1;
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": error connecting account. try again in " + next + "s for the " + attempt + " time. lowPingTimeout=" + lowPingTimeoutMode);
|
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": error connecting account. try again in " + next + "s for the " + attempt + " time. lowPingTimeout=" + lowPingTimeoutMode+", aggressive="+aggressive);
|
||||||
scheduleWakeUpCall(next, account.getUuid().hashCode());
|
scheduleWakeUpCall(next, account.getUuid().hashCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -948,7 +949,8 @@ public class XmppConnectionService extends Service {
|
||||||
scheduleWakeUpCall((int) Math.min(timeout, discoTimeout), account.getUuid().hashCode());
|
scheduleWakeUpCall((int) Math.min(timeout, discoTimeout), account.getUuid().hashCode());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (account.getXmppConnection().getTimeToNextAttempt() <= 0) {
|
final boolean aggressive = hasJingleRtpConnection(account);
|
||||||
|
if (account.getXmppConnection().getTimeToNextAttempt(aggressive) <= 0) {
|
||||||
reconnectAccount(account, true, interactive);
|
reconnectAccount(account, true, interactive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4590,6 +4592,10 @@ public class XmppConnectionService extends Service {
|
||||||
return this.mJingleConnectionManager;
|
return this.mJingleConnectionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasJingleRtpConnection(final Account account) {
|
||||||
|
return this.mJingleConnectionManager.hasJingleRtpConnection(account);
|
||||||
|
}
|
||||||
|
|
||||||
public MessageArchiveService getMessageArchiveService() {
|
public MessageArchiveService getMessageArchiveService() {
|
||||||
return this.mMessageArchiveService;
|
return this.mMessageArchiveService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2483,10 +2483,15 @@ public class XmppConnection implements Runnable {
|
||||||
return servers.size() > 0 ? servers.get(0) : null;
|
return servers.size() > 0 ? servers.get(0) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTimeToNextAttempt() {
|
public int getTimeToNextAttempt(final boolean aggressive) {
|
||||||
|
final int interval;
|
||||||
|
if (aggressive) {
|
||||||
|
interval = Math.min((int) (3 * Math.pow(1.3,attempt)), 60);
|
||||||
|
} else {
|
||||||
final int additionalTime =
|
final int additionalTime =
|
||||||
account.getLastErrorStatus() == Account.State.POLICY_VIOLATION ? 3 : 0;
|
account.getLastErrorStatus() == Account.State.POLICY_VIOLATION ? 3 : 0;
|
||||||
final int interval = Math.min((int) (25 * Math.pow(1.3, (additionalTime + attempt))), 300);
|
interval = Math.min((int) (25 * Math.pow(1.3, (additionalTime + attempt))), 300);
|
||||||
|
}
|
||||||
final int secondsSinceLast =
|
final int secondsSinceLast =
|
||||||
(int) ((SystemClock.elapsedRealtime() - this.lastConnect) / 1000);
|
(int) ((SystemClock.elapsedRealtime() - this.lastConnect) / 1000);
|
||||||
return interval - secondsSinceLast;
|
return interval - secondsSinceLast;
|
||||||
|
|
|
@ -158,6 +158,21 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasJingleRtpConnection(final Account account) {
|
||||||
|
for (AbstractJingleConnection connection : this.connections.values()) {
|
||||||
|
if (connection instanceof JingleRtpConnection) {
|
||||||
|
final JingleRtpConnection rtpConnection = (JingleRtpConnection) connection;
|
||||||
|
if (rtpConnection.isTerminated()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (rtpConnection.id.account == account) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void notifyPhoneCallStarted() {
|
public void notifyPhoneCallStarted() {
|
||||||
for (AbstractJingleConnection connection : connections.values()) {
|
for (AbstractJingleConnection connection : connections.values()) {
|
||||||
if (connection instanceof JingleRtpConnection) {
|
if (connection instanceof JingleRtpConnection) {
|
||||||
|
@ -170,6 +185,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Optional<RtpSessionProposal> findMatchingSessionProposal(
|
private Optional<RtpSessionProposal> findMatchingSessionProposal(
|
||||||
final Account account, final Jid with, final Set<Media> media) {
|
final Account account, final Jid with, final Set<Media> media) {
|
||||||
synchronized (this.rtpSessionProposals) {
|
synchronized (this.rtpSessionProposals) {
|
||||||
|
|
Loading…
Reference in a new issue