title: Iphone Voip app - Backgrounding and keeping nat pinhole alive
body: <p>I am testing a Voip sip client written by an iphone app developer that uses PJSip. I personally have toyed around with some SIP development myself but am no expert.</p>
  
  <p>With our VOIP softswitch (Acme packet / Broadsoft), it takes care of all the Nat Handling by dynamically determining the best Re-register time to keep the Nat pinhole alive on the nat device.  Typically when the iphone is behind a NAT this time is between 60-90 seconds.</p>
  
  <p>The Iphone App is using TCP and happily works with Backgrounding.  Obviously backgrounding is ideal to save on the battery life.  The call wakes up the phone and you can listen to the call.</p>
  
  <p>The problem is that when the App goes into Background mode, it has no way of keeping the Nat Pinhole open.  This means the firewall will always reject new incoming calls from reaching the Iphone App once the pinhole is closed. This has the affect of incoming calls working to the app for a few minutes, then not working for a period, and then when the app comes out of background and registers again, the inbound calls work again. </p>
  
  <p>According to the apple documentation:
  <a href="http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW3">http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW3</a></p>
  
  <p>They have inbuilt special exceptions for voip applications for backgrounding we can:
  1. Configure the Apps sockets such that they can still handle incoming messaging.  This doesn't help as the messaging will never reach the app if the nat pinhole is closed.
  2. Use a Keep alive, however the minimum time is 600 seconds.  This also means the pinhole will close.</p>
  
  <p>Is there some clever way an App can send a Voip Sip registration message, say every 60 seconds or so whilst remaining in the background.  Or can the app wake up every 60 seconds do some work and then close.</p>
  
  <p>Im really perplexed as to whether or not there are other sip apps on the market that have got around this problem.</p>