powered by Jive Software

Reconnection Logic For ANDROID

Hi Guys,
Our team has working on IM app based on XMPP. We have used smack for that on the client side. These are some important highlights about our connection.

  1. Client sends Pings every 5 sec to check the network connection.
  2. Client has used reconnectionManager from the smack library.
  3. Client also using Stream management.

We are observing the following problems.

  1. The connection on the mobile remains for 6 to 7 hours but then it disconnects and does not reconnect.
  2. Pings from the server are failing after a long period of connectivity.
  3. The ReconnectionManager is trying the multiple reconnects and enables a new stream 5 to 9 times and then sends the request which is totally not expected.

What are the points we are lagging so that we can build a persisitent connection in android which remains for endless period of time.

1 Like

For the sake of battery consumption please use a higher ping interval. Something like 15/30 minutes scheduled by Android’s AlarmManager, which gives Android the opportunity to batch those, is sensible. Everything lower 15 minutes is just impolite towards the user.

1 Like

Hi @Flow, thanks for the recommendation. we will use it and check whether the connection is breaking or not .

Also but the main problem is we are facing a problem in which we just cannot connect to the server after a long period of time.

Also it would be helpful if you can direct me to some reconnection logic so that the 3rd issue i am facing in will not be faced again.

Am also learning so I don’t have much to say. But I’m also curious how do you manage when there is no connection like user turns off the WiFi/Data for long time and re-switches on. I know you can listen to than and recreate connection, but where do you store user credentials for re-login? Or you just log user out and ask for new login?

I would store credentials in the Android Key Store], eg. using Jetpack Security.

I don’t really understand what you mean?

1 Like

Never knew it existed. Thanks for pointing out

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.