From 62a379862e3ccbcaa4631960da4dedeaa9e0517d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 1 Aug 2022 10:14:49 +0200 Subject: [PATCH] jingle rtp: improve logging and error reporting --- .../eu/siacs/conversations/parser/AbstractParser.java | 2 +- .../java/eu/siacs/conversations/parser/MessageParser.java | 3 ++- .../xmpp/jingle/JingleConnectionManager.java | 4 ++-- .../conversations/xmpp/jingle/JingleRtpConnection.java | 8 ++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java index 000fa036d..f4b01b7d3 100644 --- a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java +++ b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java @@ -126,7 +126,7 @@ public abstract class AbstractParser { return user; } - public static String extractErrorMessage(Element packet) { + public static String extractErrorMessage(final Element packet) { final Element error = packet.findChild("error"); if (error != null && error.getChildren().size() > 0) { final List errorNames = orderedElementNames(error.getChildren()); diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 86799bd11..5c66451ce 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -327,7 +327,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece } if (id.startsWith(JingleRtpConnection.JINGLE_MESSAGE_PROCEED_ID_PREFIX)) { final String sessionId = id.substring(JingleRtpConnection.JINGLE_MESSAGE_PROCEED_ID_PREFIX.length()); - mXmppConnectionService.getJingleConnectionManager().failProceed(account, from, sessionId); + final String message = extractErrorMessage(packet); + mXmppConnectionService.getJingleConnectionManager().failProceed(account, from, sessionId, message); return true; } mXmppConnectionService.markMessage(account, diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java index 0f9694915..416877236 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java @@ -908,12 +908,12 @@ public class JingleConnectionManager extends AbstractConnectionManager { } } - public void failProceed(Account account, final Jid with, String sessionId) { + public void failProceed(Account account, final Jid with, final String sessionId, final String message) { final AbstractJingleConnection.Id id = AbstractJingleConnection.Id.of(account, with, sessionId); final AbstractJingleConnection existingJingleConnection = connections.get(id); if (existingJingleConnection instanceof JingleRtpConnection) { - ((JingleRtpConnection) existingJingleConnection).deliverFailedProceed(); + ((JingleRtpConnection) existingJingleConnection).deliverFailedProceed(message); } } diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java index fd918fa9b..353851c37 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -797,7 +797,7 @@ public class JingleRtpConnection extends AbstractJingleConnection } catch (final WebRTCWrapper.InitializationException e) { Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable to initialize WebRTC"); webRTCWrapper.close(); - sendSessionTerminate(Reason.FAILED_APPLICATION); + sendSessionTerminate(Reason.FAILED_APPLICATION, e.getMessage()); return; } final org.webrtc.SessionDescription sdp = @@ -928,10 +928,10 @@ public class JingleRtpConnection extends AbstractJingleConnection } } - void deliverFailedProceed() { + void deliverFailedProceed(final String message) { Log.d( Config.LOGTAG, - id.account.getJid().asBareJid() + ": receive message error for proceed message"); + id.account.getJid().asBareJid() + ": receive message error for proceed message ("+Strings.nullToEmpty(message)+")"); if (transition(State.TERMINATED_CONNECTIVITY_ERROR)) { webRTCWrapper.close(); Log.d( @@ -1270,7 +1270,7 @@ public class JingleRtpConnection extends AbstractJingleConnection webRTCWrapper.close(); final Reason reason = Reason.ofThrowable(throwable); if (isInState(targetState)) { - sendSessionTerminate(reason); + sendSessionTerminate(reason, throwable.getMessage()); } else { sendRetract(reason); }