From 73e11e3f03c791b2c01868fa1f02409d2c2baa51 Mon Sep 17 00:00:00 2001 From: damencho Date: Thu, 5 Dec 2024 11:34:27 -0600 Subject: [PATCH] fix(reconnect): Handle reconnect too quickly and fail. In case prosody is not fully up we can receive StreamErrorException: invalid-namespace and at the same time we are connected which will cause reconnection to stop. --- .../kotlin/org/jitsi/jicofo/xmpp/XmppProvider.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/XmppProvider.kt b/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/XmppProvider.kt index 76e09d136b..5180e3bb16 100644 --- a/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/XmppProvider.kt +++ b/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/XmppProvider.kt @@ -90,6 +90,18 @@ class XmppProvider(val config: XmppConnectionConfig, parentLogger: Logger) { override fun reconnectionFailed(e: Exception) { logger.error("XMPP reconnection failed: ${e.message}", e) + + if (xmppConnection.isConnected) { + xmppConnection.disconnect() + + // If there was an error reconnecting, do not give up, let's retry + // if we retry too quickly and prosody is not fully up ('invalid-namespace' error) + connectRetry.runRetryingTask( + SimpleRetryTask(0, 1000L, true) { + doConnect() + } + ) + } } }