Xmpp gets disconnected after iphone has been idle for more than 10 minutes

Possible duplicate:
How to keep iphone ios xmpp connection in background?

I use Xmpp in a chat application to send and receive messages. When the iphone goes into the background, my openfire server automatically makes my session offline. After my application wakes up, my session becomes Online in openfire and I can send and receive messages.

Probelm occurs when the iphone is idle for more than 10 minutes or so. Now that the application comes to the fore, I am not getting a list in active sessions on the openfire server. Therefore, I cannot perform chat operations.

After reading a few discussions from the net, I came to this timeout issue. This is due to a timeout. If so, will it work on the following?

File Name: XMPPStream.h

/*
  Many routers will teardown a socket mapping if there is no activity on the socket.
  For this reason, the xmpp stream supports sending keep alive data.
  This is simply whitespace, which is ignored by the xmpp protocol.
  The default value is defined in DEFAULT_KEEPALIVE_INTERVAL.
  To disable keepalive, set the interval to zero.
*/

@property (nonatomic, readwrite, assign) NSTimeInterval keepAliveInterval;

Searching for a file with the keyword "DEFAULT_KEEPALIVE_INTERVAL" brought me here ...

#if TARGET_OS_IPHONE
  #define DEFAULT_KEEPALIVE_INTERVAL 120.0 // 2 Minutes
#else
  #define DEFAULT_KEEPALIVE_INTERVAL 300.0 // 5 Minutes
#endif

Can someone suggest me a working solution? thank

+3
source share

All Articles