[Freeswitch-users] Dialplan condition to test if SIP client is registered

Thaddeus Hogan thaddeus at thogan.com
Sat May 5 09:12:32 MSD 2012


Thanks for the information. I got something working today using 
sofia_contact, but am having issues with SIP registrations surviving for 
a good deal of time after the user has disconnected from the network.

Basically, the SIP client is no longer available when the user leaves 
the building and is disconnected from Wifi.  When this happens, 
sofia_contact continues to return a value indicating the client is 
registered for quite some time.

I found the command "sofia profile <profile_name> check_sync", which I 
used successfully to invalidate registrations for users that have 
disconnected from the network. But I could not figure out how to make 
this execute before my "sofia_contact" condition in the dialplan. I am 
assuming this is because I need it to run before the ROUTING stage, and 
I can only get it to run in the EXECUTE stage.

So I have a couple questions. Is check_sync quick enough to run on every 
inbound call prior to making routing decisions? Also, according to the 
comments here http://wiki.freeswitch.org/wiki/FS_weekly_2011_06_29 I 
should be able to give check_sync a user at domain argument, but this does 
not seem to work.

Are there other ways to determine if a bridge failed because a user's 
SIP client was not reachable, versus a timeout or call rejection?

Thanks for helping with this!

-- Thaddeus

On 5/4/2012 1:24 PM, Dave R. Kompel wrote:
> Thaddeus & Michael:
> As  Michael stated there are many ways to fail over if a phone/user 
> isn't registered. However sometimes you may want to actually check the 
> registration yourself. Or even do something based on a contact being 
> registered, that has nothing to do with the actual one you are calling.
> I normally use the API: sofia_contact([profile/]<user>@domain). It 
> returns the channel string you would pass to bridge. If the user isn't 
> registered it returns "error/<the error>" so it would use the logical 
> "error" endpoint to handle the right treatment. If the regex "^error" 
> match is true, then the user isn't registered.
> The extra thing you get from that API call is that you can use a "*" 
> for the profile, and find out which SIP profile the user is registered 
> in. For example in the case of an Android client, that may be using 
> WIFI or 3G, and you have an external and internal profile they can 
> register, you can tell if the user is "on site" or "off site" by the 
> profile it returns, and can be more restrictive of the calls you send 
> to someone when they're out of the office.
> --Dave
>
>     ------------------------------------------------------------------------
>     *From:* Michael Collins [mailto:msc at freeswitch.org]
>     *To:* FreeSWITCH Users Help
>     [mailto:freeswitch-users at lists.freeswitch.org]
>     *Sent:* Fri, 04 May 2012 10:34:31 -0700
>     *Subject:* Re: [Freeswitch-users] Dialplan condition to test if
>     SIP client is registered
>
>     Hi Thaddeus,
>
>     You definitely have several options here. While you could use the
>     sofia_contact API, I'm wondering if perhaps you could let the
>     dialplan and the bridge app do the work for you.
>
>     You could bridge directly to the Android user and then if it fails
>     it could then continue in the dialplan and ring the mobile number.
>     This is covered briefly on the wiki
>     <http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_bridge#Implementing_Failover>,
>     however <shameless_plug>it is covered very nicely in the new
>     FreeSWITCH Cookbook</shameless_plug> in chapter 1.
>
>     Try out the basic failover (pipe-separated list of endpoints) and
>     if that doesn't work let us know. Maybe you could hop on IRC and
>     talk live with other community members. Of course, it can't hurt
>     to raise your karma by getting the FreeSWITCH books. :) (See
>     freeswitch.org <http://freeswitch.org/>, upper left corner.)
>
>     Thanks,
>     Michael
>
>     On Fri, May 4, 2012 at 10:10 AM, thaddeus at thogan.com
>     <mailto:thaddeus at thogan.com> <thaddeus at thogan.com
>     <mailto:thaddeus at thogan.com>> wrote:
>
>         I was wondering if there is a way to tell if a SIP client is
>         registered with a dialplan condition? Or maybe a better way to
>         accomplish the following?:
>
>         The users' cell phones (Android) are running a SIP client and
>         connect to freeswitch via Wifi when in the office. I want
>         calls destined for a given user to ring only their extension
>         if they are connected via SIP, and ring only their mobile
>         number when they are not connected.
>
>         Currently I just take every incoming call and bridge it back
>         out to their mobile number, but 95% of the time these users
>         are on the Wifi network, and I could just pass the call to
>         their phones via SIP.
>
>         I have tested hunt groups but the callers hear ringing for far
>         too long. Ring groups don't work because it is confusing when
>         the user simultaneously receiving the same call via SIP and
>         mobile on the same phone.
>
>         Thanks in advance for any insights and help!
>
>         -- Thaddeus
>         _________________________________________________________________________
>         Professional FreeSWITCH Consulting Services:
>         consulting at freeswitch.org <mailto:consulting at freeswitch.org>
>         http://www.freeswitchsolutions.com
>         <http://www.freeswitchsolutions.com/>
>
>         
>          </>
>
>         Official FreeSWITCH Sites
>         http://www.freeswitch.org <http://www.freeswitch.org/>
>         http://wiki.freeswitch.org <http://wiki.freeswitch.org/>
>         http://www.cluecon.com <http://www.cluecon.com/>
>
>         FreeSWITCH-users mailing list
>         FreeSWITCH-users at lists.freeswitch.org
>         <mailto:FreeSWITCH-users at lists.freeswitch.org>
>         http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>         UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>         http://www.freeswitch.org <http://www.freeswitch.org/>
>
>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> 
> 
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20120505/39a7c764/attachment.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list