iOS XMPP disconnect on background doesn't get reported

When the app is in the background and xmpp disconnects because the internet goes down, and if the internet comes back up, when I open the app, the disconnect call is not made so the app doesn't try to reconnect.

If i check the xmppstream is connected it shows as Yes. How can I check if the connection is still alive when I go back to the app?

Currently I am trying a disconnect, and connect each time the app wakes up. But ideal would be to detect disconnection...

Thanks

Answers


If you can detect when the app wakes up, then send a ping. If you don't get a reply, reconnect. If the XMPP lib you use has support for Stream Management, especially the stream resumption support, you could use that to pick up the stream.

A better solution would be to have a separate daemon that manages the connection, and stays alive in the background, if that's even allowed on iOS. Also, this XEP might be of interest.


If you're using XMPPFramework (https://github.com/robbiehanson/XMPPFramework), then take a look at XMPPReconnect, which will save you a lot of the hassle of reconnecting.

After the stream has been created, use the following.

xmppReconnect = [[XMPPReconnect alloc] init];
[xmppReconnect activate:xmppStream];
[xmppReconnect addDelegate:self delegateQueue:dispatch_get_main_queue()];

Need Your Help

Stack items vertically in rows/columns instead of horizontally

html css

I'm creating an html page and want to switch to scrolling and floating of the page. So within the body or a div I want a list of items. Every item should go under the previous unless the end of the...

OpenLayers map controls failing to show up over HTTPS

https openlayers

I have a OpenLayers map application running on a Django page. It uses a control panel to allow drawing on the map. We recently switched the site over to HTTPS, and now although the map loads, the