NotConnectedException when try to join a muc

When I try to join an existing group I have this crash:

org.jivesoftware.smack.SmackException$NotConnectedException: Client is not, or no longer, connected.

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.throwNotConnectedExce ptionIfDoneAndResumptionNotPossible(XMPPTCPConnection.java:1232)

at org.jivesoftware.smack.tcp.XMPPTCPConnection.throwNotConnectedExceptionIfApprop riate(XMPPTCPConnection.java:345)

at org.jivesoftware.smack.AbstractXMPPConnection.sendStanza(AbstractXMPPConnection .java:631)

at org.jivesoftware.smack.AbstractXMPPConnection.createPacketCollectorAndSend(Abst ractXMPPConnection.java:722)

at org.jivesoftware.smackx.muc.MultiUserChat.enter(MultiUserChat.java:309)

at org.jivesoftware.smackx.muc.MultiUserChat.createOrJoin(MultiUserChat.java:396)

at org.jivesoftware.smackx.muc.MultiUserChat.createOrJoin(MultiUserChat.java:372)

can anyone help me to resolve this problem ?

Smack version 4.1.5

Isn’t the message of the exception clear enough?

I want to know the cause.

I’m connected to the server, When I join a group, I don’t have this exception.
But when I receive an invitation and I want to Join this group I have always this Exception.

the cause of probleme is the nulPointerException on PacketWriter.
there is the element who cause this exception: as you see, the id of received is empty

the crash appear on the class LazyStringBuilder.java

@Override
public int length() {

if (cache != null) {

return cache.length();
}

int length = 0;
for (CharSequence csq : list) {

if (csq != null) // to prevent the crash I added this Test

length += csq.length();
}

return length;
}

@Override
public char charAt(int index) {

if (cache != null) {

return cache.charAt(index);
}

for (CharSequence csq : list) {

if (csq != null) { // to prevent the crash I added this Test

if (index < csq.length()) {

return csq.charAt(index);
} else {

index -= csq.length();
}

}

}

throw new IndexOutOfBoundsException();
}

Please try running Smack with assertions enabled.

how can I do it ?

Depends on which VM/runtime you use when executing Smack. For the standard (Oracle) JVM it’s usually -ea. LazyStringBuilder uses assertions, if you enable them, you will get an exception and a stacktrace when someone tries to insert an illegal value, i.e. ‘null’ into LazyStringBuilder.

Can you confirm that you don’t construct a DeliveryReceipt with ‘null’ as argument?

I use Smack on Android project.

I use only these 3 lines of code for the “DeliveryReceipt”:

deliveryReceiptManager = DeliveryReceiptManager.getInstanceFor(connectionChat);
deliveryReceiptManager.autoAddDeliveryReceiptRequests();
deliveryReceiptManager.setAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode.always);

What you describe could happen if someone sends you a receipt request in a message stanza which does not have its ID set. This is illegal, but Smack should handle this case nevertheless.

Created SMACK-708. Uploaded Smack 4.1.6-SNAPSHOT, which includes https://github.com/Flowdalic/Smack/commit/09364e571cb660d42a37ffd60f4c07a0be1018 ed , to Maven Central’s snapshot repoitories. Could you test and report back if it fixes the issue for you?

Thanks, I will check it.
Another question:

  • Why we send receipt request for message without body like chatState, … ?

Why we send receipt request for message without body like chatState, … ?

No particular reason, I guess the idea is that it’s better to request receipts for more messages then to less. We could filter for messages with a body too. It’s just that the current implementation doesn’t do it.

I’ve uploaded a snapshot which no longer requests receipts for messages without a body as well.

Thanks, where can I found the code source of that SNAPSHOT to integrate it in my project.

One more question: When I try to connect to the server (Case I’m of course connected), I have an exception and I can’t get the result of the function :

public AbstractXMPPConnection connect() throws SmackException, IOException, XMPPException

Why you implemented this Exception in case I’m already connected ?

Thanks, where can I found the code source of that SNAPSHOT to integrate it in my project.

In Maven Central’s snapshot repositories. The URL you have to add as repository to your build system is mentioned in Smack’s README.

One more question:

Please create a new thread for unrelated questions. I also don’t get the question, please try rewording it (and maybe exactly mention the exception you mean).