powered by Jive Software

ConnectionListener not aware of connection breakdown

Hi, I’m using Smack 3_2_1 to connect and send messages to an XMPP server.

I wanted to use ConnectionListener in order to know when the connection is not reachable:

=====================================

ConnectionListener cL = new ConnectionListener() {

//overrided methods

};

conn.addConnectionListener(cL);

======================================

While the connection is stablished I forced down my connection (ifconfig eth0 down)

which does not launch any method of the ConnectionListener.

¿Is that the way to wait for connection breakdown events?

¿Is there any way to be aware of a lack of connection?

Thank you in advanced.

Malon
Drawing1.vsd.zip (152538 Bytes)

I know this question is old, but it describes my own problem. Differences:

  1. I’m using 3.1.0 (asmack)
  2. sometimes the callback is fired, and sometimes not (but most of the times not)
    I know, that smack sends some sort of ping to server, but even if I wait for 15 minutes the callback is not fired, so that’s not the case of intervals (beside, I manually set it to 1 second).

Help, anyone?

Smack only sends a whitespace ping to the server, which is in most cases not sufficient to recognize a connection interruption in mobile environments. The result is that the ConnectionListeners often won’t be called.

I have development XEP-199 support fo Smack with a periodic ping thread. The current code is within the GTaklSMS repository, but I plan to move it to smack and aSmack in the next few weeks (see SMACK-388). Until then you can simply copy the files from GTalkSMS and report any issues you may encounter.

But note that XEP-199 is not the silver bullet on Android. I recommend to also listen for CONNECTIVITY_CHANGE intents and take the according actions.

Why you are using a old asmack version anyway?

Thanks for your reply, flow!

Sorry for such a long resonse time, I think I should’ve got an email notification about your reply, but obviously I have not.

I’ll look into link you provided.

Why you are using a old asmack version anyway?

Well I inherited this project, so I never realized that was an old version. Thanks for info!