NotConnectedException while connected?

Hi, when I’m setting presence, i get a NotConnectedException, while i don’t see a disconnect and the new presence seems to be sent.

try {

_connection.sendStanza(_presence);
} catch (SmackException.NotConnectedException e) {

Log.e(TAG, “setPresence() failed: Not connected”);
e.printStackTrace();
}

Wow it’s quite hard to send a post… It first lost my text and then suddenly posted incomplete text.

Anyway, i added more info:

  • I’m running this on android 5.1.1

  • I’m using smack 4.1.3

Here is the log:

08-05 15:22:49.854 E/nl.dobots.imbusy.XmppThread( 9483): Not connected

08-05 15:22:49.854 W/System.err( 9483): org.jivesoftware.smack.SmackException$NotConnectedException: Client is not, or no longer, connected

08-05 15:22:49.854 W/System.err( 9483): at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.throwNotConnectedExce ptionIfDoneAndResumptionNotPossible(XMPPTCPConnection.java:1230)

08-05 15:22:49.854 W/System.err( 9483): at org.jivesoftware.smack.tcp.XMPPTCPConnection.throwNotConnectedExceptionIfApprop riate(XMPPTCPConnection.java:336)

08-05 15:22:49.854 W/System.err( 9483): at org.jivesoftware.smack.AbstractXMPPConnection.sendStanza(AbstractXMPPConnection .java:614)

08-05 15:22:49.855 W/System.err( 9483): at nl.dobots.imbusy.XmppThread.setPresence(XmppThread.java:190)

08-05 15:22:49.855 W/System.err( 9483): at nl.dobots.imbusy.XmppThread.access$100(XmppThread.java:25)

08-05 15:22:49.855 W/System.err( 9483): at nl.dobots.imbusy.XmppThread$MessageHandler.handleMessage(XmppThread.java:81)

08-05 15:22:49.855 W/System.err( 9483): at android.os.Handler.dispatchMessage(Handler.java:102)

08-05 15:22:49.855 W/System.err( 9483): at android.os.Looper.loop(Looper.java:135)

08-05 15:22:49.855 W/System.err( 9483): at android.os.HandlerThread.run(HandlerThread.java:61)

08-05 15:22:08.277 D/SMACK ( 9483): RECV (1): dnd

08-05 15:22:08.277 D/SMACK ( 9483): RECV (1)
You notice that it says RECV here?

Yes i do, but someone must’ve changed the presence, and that could’ve been only that code, i think.

Possible. Hard to tell without more information. Please show more debug log context, and elaborate what you mean with “i don’t see a disconnect”. Do you install a ConnectionListener that acts on connectionClosedOnError(Exception)?

Was planning to do exactly that On pidgin i didn’t see it disconnect, but mostly i was amazed that the presence was still sent out.

So I now added the listener and of course now i’m unable to reproduce the error…

Will post again if i’m able to, thanks.