From 584d68677d3a57bcd23a001900ddf4d08c7b87d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=8F=D0=BD=20=D0=9C=D0=B8=D0=BD=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Thu, 5 Dec 2024 13:06:08 -0600 Subject: [PATCH] fix: Reconnect after an error. (#1199) With Stream Management enabled ReconnectManager stops trying in some cases if the connection is closed with an error. We see that XMPPTCPConnection.connected=true in that case (TCP connection open, but an attempt to login fails). --- .../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() + } + ) + } } }