Skip to content

Commit

Permalink
fix(reconnect): Handle - reconnect too quickly and fail. (#212)
Browse files Browse the repository at this point in the history
* 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.

* squash: Bump smack version and fix error already connected.
  • Loading branch information
damencho authored Dec 5, 2024
1 parent 3afa2ac commit 9a9091d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions jicoco/src/main/java/org/jitsi/xmpp/mucclient/MucClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,17 @@ public void reconnectionFailed(Exception e)
{
mucClientManager.reconnectionFailed(MucClient.this);
logger.warn("Reconnection failed: ", e);

// If there was an error reconnecting, do not give up, let's retry (reconnection stops if the connection
// is connected, but we have another error after the connection is established). This can happen if we retry
// too quickly and prosody is not fully up ('invalid-namespace' error)
if (MucClient.this.connectRetry != null && xmppConnection.isConnected())
{
xmppConnection.instantShutdown();

MucClient.this.connectRetry.runRetryingTask(
new SimpleRetryTask(0, 2000, true, getConnectAndLoginCallable()));
}
}
};

Expand Down Expand Up @@ -675,10 +686,7 @@ private Callable<Boolean> getConnectAndLoginCallable()
{
try
{
if (!xmppConnection.isConnected())
{
xmppConnection.connect();
}
xmppConnection.connect();
}
catch(Exception t)
{
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<jersey.version>3.0.10</jersey.version>
<jwt.version>0.12.6</jwt.version>
<bouncycastle.version>1.78.1</bouncycastle.version>
<smack.version>4.4.6</smack.version>
<smack.version>4.4.8</smack.version>
</properties>

<dependencyManagement>
Expand Down

0 comments on commit 9a9091d

Please sign in to comment.