This is from the official docs and might help you out.
https://trac.pjsip.org/repos/wiki/Getting-Started/iPhone#keepalive
As the process is normally suspended when application is in the
background, the worker thread that handles TCP keepalive timer is also
suspended. So basically application needs to schedule periodic wakeup
to allow the library send TCP keep-alive.
Modify your AppDelegate.m to something like this-
- (void)keepAlive {
/* Register this thread if not yet */
if (!pj_thread_is_registered()) {
static pj_thread_desc thread_desc;
static pj_thread_t *thread;
pj_thread_register("mainthread", thread_desc, &thread);
}
/* Simply sleep for 5s, give the time for library to send transport
* keepalive packet, and wait for server response if any. Don't sleep
* too short, to avoid too many wakeups, because when there is any
* response from server, app will be woken up again (see also #1482).
*/
pj_thread_sleep(5000);
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
/* Send keep alive manually at the beginning of background */
pjsip_endpt_send_raw*(...);
/* iOS requires that the minimum keep alive interval is 600s */
[application setKeepAliveTimeout:600 handler: ^{
[self performSelectorOnMainThread:@selector(keepAlive)
withObject:nil waitUntilDone:YES];
}];
}