[asterisk-users] is chanisavail command reliable?

Andrew Kohlsmith akohlsmith-asterisk at benshaw.com
Mon Sep 18 10:46:41 MST 2006


On Monday 18 September 2006 04:53, Giorgio Incantalupo wrote:
> What I do is:
> 1) use "chanisavail" command to ask Asterisk for a free channel to use
> 2) use that channel to dial outbound calls

The problem is that a race condition exists; the channel could be available at 
time (1), but something could snag it at time (2).  There (currently) is no 
way to lock a channel after it's been detected as free so that something 
later could use it.

My suggestion isn't to use ChanIsAvail() at all; simply Dial and catch 
${DIALSTATUS}, like so:

exten => foo,1,Dial(Tech/exten,,g)
exten => foo,n,Goto(foo-${DIALSTATUS},1)

exten => foo-CHANUNAVAIL,1,NoOp(Nope, wasn't available, gotta do something 
else...)
exten => foo-BUSY,1,NoOp(busy...)
exten => foo-NOANSWER,1,NoOp(no answer...)

that way there is no race condition.  What would maek this better is if you 
could group a bunch of channels, irrespective of technology, together and 
dial that group... something like this

(assume a groups.conf)
1 => SIP/500, IAX2/user at peer/${EXTEN}, Zap/g1
2 => Zap/1,Zap/3,Zap/5
3 => SIP/${EXTEN}@peer

and then do something like this:

exten => _NXXNXXXXXX,1,Dial(GROUP/1,,g)

which would dial SIP/500, IAX2/user at peer/9165551212 and the first available 
channel in the Zaptel group 1...  (assuming 9165551212 was what matched)...

variable expansion would be crucial in this kind of design.  :-)

-A.

>
> Asterisk gives me the free channel but when I make a call Asterisk tells
> me the channel is not available (I check variable ${AVAILSTATUS}). I
> checked but that channel is not busy on another call.
> How can it be possible? Is there anybody who can help me?
>
> TIA
>
>
> Giorgio Incantalupo
>
>
>
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users


More information about the asterisk-users mailing list