0

I have an app based on pjsip for doing some Sip calls.

The app works fine with other SIP Switches/servers but with freeSwitch the app is not receiving calls in the background mode.

With freeSwitch everything is fine when the app is active but when in background mode the app is not notified about the call. It has, probably, something to do with how freeSwitch notify the app about the new call (for iOS pjsip the notification should come on the TCP wrapped socket).

Dose anybody know how i can configure the fresSwitch to send the notification on a specific port?

alinoz
  • 2,822
  • 22
  • 38
  • Does your app register to FreeSWITCH? It may be the fact that the registration has timed out and FreeSWITCH doesn't know where your app endpoint is. What does debug 7 show in FreeSWITCH? Can you explain more about the functionality you are after? – Gavin Henry Nov 29 '11 at 23:58
  • the app is registered,because if i'm opening the app (from the background) I get the call notification. – alinoz Nov 30 '11 at 08:20

2 Answers2

0

I mange to solve this problem by adding:

<variable name="sip-force-contact" value="NDLB-connectile-dysfunction"/>

into freeswitch_install_folder/conf/directory/default/XYZ.xml (where XYZ is the user you are configuring) under variables.

alinoz
  • 2,822
  • 22
  • 38
0

You don't want to use ndlb-connectile-dysfunction (ndlb) for iOS with Freeswitch. Doing so will guarantee you can't hold a registration open long enough to be useful in the background, because Freeswitch appends "expires=30" to all registrations when that option is set. After that you'll just get a "USER_NOT_REGISTERED" error when trying to call that user, unless it happens to be within 30 seconds after a registration call.

What you need to do is follow the steps here: http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW12

Specifically:

1) make sure you have an iOS keep-alive timer running (setKeepAliveTimeout:handler:), with the handler block doing a re-register at the minimum value (600 seconds).

2) make sure your app is configured for VOIP and audio playback background modes in its Info.plist

3) make sure your client is registering the network stream interface for VOIP usage as noted in those Apple guidelines. That way the OS can put the app to sleep, but wake you up if incoming traffic occurs on that network stream.

If you do all three of those, you should be able to run voip just fine in the background on iOS 5, even with the screen locked.

sounder_michael
  • 576
  • 6
  • 17
  • Did all the steps mentioned by you and the app was running fine with other SIP Servers but it did not work in background mode with FreeSwitch server. the problem was not in the iOS side. – alinoz Jan 29 '12 at 01:52
  • Were you using TCP for the SIP registrations? I'm having no trouble using FreeSwitch with iOS 5 in background mode. At any rate, users will want to stay far away from the NDLB setting. – sounder_michael Jan 29 '12 at 20:22
  • To clarify, if you use the NDLB setting, it will almost never work, and it'll have nothing to do with iOS -- it'll be because the server isn't sending anything to the phone, because the registration expired 30 seconds after registering. To get better debugging information from Freeswitch, it should be started with: `>TPORT_LOG=1 ./freeswitch` -- then it's just a matter of making sure the server is sending the calls (visible in server logs), and that the OS is waking up the app to receive it (putting a log in the callback will do). – sounder_michael Jan 29 '12 at 20:40
  • Again with this option is working without it is not working! Can I be more clear? The problem is that when in background mode, the app should receive communications on the same TCP port. It is possible that freeSwitch has a bug inside and by enabling this feature that bug is bypassed. NDLB settings are doing couple of things and one of them is " will force FreeSWITCH to send SIP responses to the network port from which they were received". – alinoz Jan 30 '12 at 13:41
  • 1
    That's not why I'm posting this. I will tell you that what's happening is possibly not what you think is happening, but if "works / doesn't work" is as deep as you want to go, that's your prerogative. The point is that people looking for help on iOS who find this post shouldn't follow the advice to use that NDLB setting. They should figure out what stage of the process is failing (NAT traversal, SIP registration, automatic wake from sleep, etc.), and fix that instead. If NDLB seems to be working in extended testing, then most likely the app isn't sleeping when put to the background. – sounder_michael Jan 30 '12 at 21:06
  • The problem is automatic wake from sleep and for this the app should get notifications on the same port it has sent the REGISTER message. So do you have a clue how could I force FreeSwitch to do this without NDLB? Without NDLB FreeSwitch is sending the call notification on a different port and for sure the iOS app is not ab le to take the answer. – alinoz Jan 30 '12 at 21:09