From 3ece613a5d35b5a134281638d7d1e308774e940d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 25 May 2017 14:40:59 +0200 Subject: [PATCH] rename resource on bind conflict --- .../java/eu/siacs/conversations/xmpp/XmppConnection.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index b7393231a..57fb158e1 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -1044,7 +1044,13 @@ public class XmppConnection implements Runnable { } else { Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure (" + packet.toString()); } - account.setResource(account.getResource().split("\\.")[0]); + final Element error = packet.findChild("error"); + final String resource = account.getResource().split("\\.")[0]; + if (packet.getType() == IqPacket.TYPE.ERROR && error != null && error.hasChild("conflict")) { + account.setResource(resource + "." + nextRandomId()); + } else { + account.setResource(resource); + } throw new StateChangingError(Account.State.BIND_FAILURE); } });