Stream Management only enabled after first reconnection

I upgraded to Smack 4.1.1, upgraded to latest Tigase(version 7.0.1) & traced Smack code. It seems that even though I call the required methods(as follows in enableStream() method) for enabling stream after XMPPTCPConnection.login(), the stream gets enabled only after the first successful reconnect. At first I called enableStream() directly after successful login, but now I am calling it from connectionlistener::authenticated() method when resume is false but the behavior(i.e. stream enabling after first reconnect) is same.

So, after first reconnect the stream gets opened(i.e. control goes to XMPPTCPConnection::parsePackets() method’s line 1081(which is “LOGGER.fine(“Stream Management (XEP-198): succesfully enabled”);”). Any messages sent to receiver when the network connection is disabled(the first time) are lost although they have been successfully received by server & are logged properly. After receiver reconnects & I disable the network connection for the second time & enable it, during reconnect, control reaches line 1120 of XMPPTCPConnection(which is "LOGGER.fine(“Stream Management (XEP-198): Stream resumed”);). Any messages sent to the receiver during the time network was down get successfully received thereafter.

private void enableStream(XMPPTCPConnection connection){

boolean isStreamAvailable = connection.isSmAvailable(); //Always returns true





boolean isStreamSet = connection.isSmEnabled(); //False after first call, true after successfult reconnect


I think I am missing something basic here. In addition, despite initializing SmackConfiguration.DEBUG to true, I don’t

see the Smack Debug output in logcat. Is there something additional which needs to be done ? I am running the code(which

uses Samack) on Android Kitkat v4.4.2.

Can anyone please help.


but now I am calling it from connectionlistener::authenticated() method
That’s to late. You need to enable SM before authentication. Simply

static {




should do the trick.

Also please don’t use existing threads, start a new ones instead if you don’t have exactly the same problem.

Thanks a lot. Runs perfectly.