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 java.util.Set;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Conversational; import eu.siacs.conversations.entities.Conversational;
import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Message;
@ -238,7 +239,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
try { try {
sdp = candidate.toSdpAttribute(ufrag); sdp = candidate.toSdpAttribute(ufrag);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.d(Config.LOGTAG,id.account.getJid().asBareJid()+": ignoring invalid ICE candidate "+e.getMessage()); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": ignoring invalid ICE candidate " + e.getMessage());
continue; continue;
} }
final String sdpMid = content.getKey(); final String sdpMid = content.getKey();
@ -658,35 +659,44 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
private void send(final JinglePacket jinglePacket) { private void send(final JinglePacket jinglePacket) {
jinglePacket.setTo(id.with); jinglePacket.setTo(id.with);
xmppConnectionService.sendIqPacket(id.account, jinglePacket, (account, response) -> { xmppConnectionService.sendIqPacket(id.account, jinglePacket, this::handleIqResponse);
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);
this.webRTCWrapper.close();
final State target;
if (Arrays.asList(
"service-unavailable",
"recipient-unavailable",
"remote-server-not-found",
"remote-server-timeout"
).contains(errorCondition)) {
target = State.TERMINATED_CONNECTIVITY_ERROR;
} else {
target = State.TERMINATED_APPLICATION_FAILURE;
}
if (transition(target)) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": terminated session with " + id.with);
} else {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": not transitioning because already at state=" + this.state);
}
} else if (response.getType() == IqPacket.TYPE.TIMEOUT) { private synchronized void handleIqResponse(final Account account, final IqPacket response) {
this.webRTCWrapper.close(); if (response.getType() == IqPacket.TYPE.ERROR) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received IQ timeout in RTP session with " + id.with + ". terminating with connectivity error"); final String errorCondition = response.getErrorCondition();
transition(State.TERMINATED_CONNECTIVITY_ERROR); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received IQ-error from " + response.getFrom() + " in RTP session. " + errorCondition);
this.jingleConnectionManager.finishConnection(this); 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(
"service-unavailable",
"recipient-unavailable",
"remote-server-not-found",
"remote-server-timeout"
).contains(errorCondition)) {
target = State.TERMINATED_CONNECTIVITY_ERROR;
} else {
target = State.TERMINATED_APPLICATION_FAILURE;
}
if (transition(target)) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": terminated session with " + id.with);
} else {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": not transitioning because already at state=" + this.state);
}
} else if (response.getType() == IqPacket.TYPE.TIMEOUT) {
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) { private void terminateWithOutOfOrder(final JinglePacket jinglePacket) {