I am using Asterisk (13) to provide SIP/Voice for an app running on iPhones - they are all connected via wifi and TCP as transport, and in general this works great.
But wifi is not always reliable, and when someone walks out of coverage I like asterisk to find out reasonably fast, Today I am using qualify for this, in the dialplan it fails nicely to CHANUNAVAIL without any issues, and I can use ${DEVICE_STATE(SIP/xxx) to check status programmatically.
iPhones are slow when an app is background and screen off - we often see a TCP packet taking 1 to 2 seconds to go from “the air” to the App, we assume this is some iPhone power saving mechanism in the OS - by adjusting qualify=yes to qualify=4000 we have overcome the majority of the iphone-latency stuff.
One of the other issues is that qualify creates is overhead - with a few thousand registered peers it will add up.
I have been reading about and experimenting with turning qualify off and using keepalive - but the issue is that it doesnt affect the dialplan that I can see, and I can’t find a way to find a “bad” status without actually parsing logs.
In the logs/console I see this when a device App gets killed (meaning socket closed without deregister):
[2016-02-16 13:48:02] WARNING[31258]: chan_sip.c:29304 sip_send_keepalive: sip_send_keepalive to 172.16.254.167:49231 returned 0: Success
If i try a call to this user i see this message:
[2016-02-16 13:48:18] WARNING[10939][C-00000003]: chan_sip.c:3740 __sip_xmit: sip_xmit of 0x7f3e8400c780 (len 914) to 172.16.254.167:49231 returned -2: Broken pipe
but it still rings for the Ringtimer timeout.
So the first thing that is weird is that what should be a broken tcp is actually “success” but shown as a warning - if the device app is alive it shows nothing.
So it appears that keepalive is purely for NAT helping - but I wonder if there would be a fairly simple way to figure out a way to “grab the keepalive status” in the dialplan?
Or if perhaps there are some other options I dont know about - basically It would be awesome to get something to work the way CUCM does, it does not qualify, but it knows quite quickly if a wifi phone goes offline…
I am not a C programmer btw - but if there are some patches out there that can do this kind of stuff I’ll try it out