ignore iq errors if session has already been terminated

This commit is contained in:
Daniel Gultsch 2020-04-17 10:56:27 +02:00
parent fa3ef07580
commit 2f437ea845
1 changed files with 38 additions and 28 deletions

View File

@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Set;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Conversational;
import eu.siacs.conversations.entities.Message;
@ -658,10 +659,17 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
private void send(final JinglePacket jinglePacket) {
jinglePacket.setTo(id.with);
xmppConnectionService.sendIqPacket(id.account, jinglePacket, (account, response) -> {
xmppConnectionService.sendIqPacket(id.account, jinglePacket, this::handleIqResponse);
}
private synchronized void handleIqResponse(final Account account, final IqPacket response) {
if (response.getType() == IqPacket.TYPE.ERROR) {
final String errorCondition = response.getErrorCondition();
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received IQ-error from " + response.getFrom() + " in RTP session. " + errorCondition);
if (TERMINATED.contains(this.state)) {
Log.i(Config.LOGTAG, id.account.getJid().asBareJid() + ": ignoring error because session was already terminated");
return;
}
this.webRTCWrapper.close();
final State target;
if (Arrays.asList(
@ -679,14 +687,16 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
} else {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": not transitioning because already at state=" + this.state);
}
} else if (response.getType() == IqPacket.TYPE.TIMEOUT) {
this.webRTCWrapper.close();
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received IQ timeout in RTP session with " + id.with + ". terminating with connectivity error");
if (TERMINATED.contains(this.state)) {
Log.i(Config.LOGTAG, id.account.getJid().asBareJid() + ": ignoring error because session was already terminated");
return;
}
this.webRTCWrapper.close();
transition(State.TERMINATED_CONNECTIVITY_ERROR);
this.jingleConnectionManager.finishConnection(this);
}
});
}
private void terminateWithOutOfOrder(final JinglePacket jinglePacket) {