Changes between Version 63 and Version 64 of Getting-Started/iPhone

May 23, 2014 11:32:57 AM (6 years ago)

Add info for SIP transport keepalive in background


  • Getting-Started/iPhone

    v63 v64  
    179179Go to System Preferences > Sound > Sound Effects and then uncheck and recheck "Play user interface sound effects". If it still doesn't work, you can try some other suggestions [ here]. 
     181=== SIP transport keepalive while in background === #keepalive 
     183As 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. Sample code: 
     185- (void)keepAlive { 
     186    /* Register this thread if not yet */ 
     187    if (!pj_thread_is_registered()) { 
     188        static pj_thread_desc   thread_desc; 
     189        static pj_thread_t     *thread; 
     190        pj_thread_register("mainthread", thread_desc, &thread); 
     191    } 
     193    /* Simply sleep for 5s, give the time for library to send transport 
     194     * keepalive packet, and wait for server response if any. Don't sleep 
     195     * too short, to avoid too many wakeups, because when there is any 
     196     * response from server, app will be woken up again (see also #1482). 
     197     */ 
     198    pj_thread_sleep(5000); 
     201- (void)applicationDidEnterBackground:(UIApplication *)application 
     203    /* Send keep alive manually at the beginning of background */ 
     204    pjsip_endpt_send_raw*(...); 
     206    /* iOS requires that the minimum keep alive interval is 600s */ 
     207    [application setKeepAliveTimeout:600 handler: ^{ 
     208        [self performSelectorOnMainThread:@selector(keepAlive) 
     209              withObject:nil waitUntilDone:YES]; 
     210    }]; 
     214Make sure that keepalive feature of SIP transport is not disabled, see [ PJSIP_TCP/TLS_KEEP_ALIVE_INTERVAL] docs, and the keepalive interval is set to less than 600s. 
     216Alternatively, configuring server to send keepalive ping packet, if possible, and client responds back by sending keepalive pong to the server, so we have two-way traffic. As there is no way to detect incoming ping from server, currently application can just always send pong packet whenever it becomes active (application will be woken up when receiving TCP packet), e.g: send pong packet in UIApplication::applicationDidBecomeActive(). 
    181218=== List of Issues === 
    190227 * [ iPhone Audio Driver] by [ Voalté] 
    191228 * [ TabikPhone], an adaptation of Sipphone code from V-Net Corp