Reconnection

Hi- is there anything special one needs to do to complete a “reconnection” event? Here’s the scenario/problem I am having:

  • I have an XMPPConnection that is working fine

  • I disconnect the network and see that the XMPPConnection becomes disconnected

  • I reconnect the network but the XMPPConnection is an odd state… I see the roster, but there is no presence information for any of the buddies, and other clients with my user as a buddy show me as offline. Other messages (IQ, etc) seem to be failing as well.

I am doing nothing other than logging the “reconnected” event. Any ideas?

Thanks,

Dan

I’m not sure if these steps are required, but in my application I remove the roster listener upon disconnects and add it upon connecting. I also re-send my current presence upon reconnecting. I don’t know if this solves all problems though, because I thought I had still noticed some flaky behavior with the reconnection code on occasion.

Chris

I did some more testing and here’s what I discovered: At the time reconnectionSuccessful() is called by the ReconnectionManager, the XMPPConnection WAS connected but had NOT been re-authenticated. This caused a race condition in my code where it basically was acting on the re-connected connection immediately even though it was not really ready.

After more tracing and debugging I finally figured out the problem- the call to reconnectionSuccessful() happens in the same thread as the underlying reconnection events, and apparently before the re-login. Since I was acting on the reconnection inline with the method call, all of my reconnection code was happening before the login, and the login was blocked by my actions.

Once I put my reconnection logic in a new thread (plus a small delay for good measure), everything worked great.

Thanks!

Dan