Possible Duplicate:
How to keep iphone ios xmpp connection alive while in the background?
I am using Xmpp in my chat application to send and receive messages.When the iphone goes into background , my openfire server automatically makes my session as Offline . After my app is awaken , my session becomes Online in openfire and am able to send and receive messages.
Probelm occurs when the iphone is in idle state for more than 10 mins or so. Now when the app comes into foreground, am not getting listed under the active sessions in openfire server . So am not able to perform chat operations obviously.
After reading few discussions from net , I arrived at this timeout problem . Is it due to the timeout . If it is , Will working on the following help me ?
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 the file for the keyword "DEFAULT_KEEPALIVE_INTERVAL" led 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 anyone suggest me a working solution ? Thanks