[Home]

Summary:ASTERISK-08076: Cmd ChanIsAvail() does not return predictable status codes.
Reporter:Mercestes D'Moriarty (mercestes)Labels:
Date Opened:2006-11-07 09:23:19.000-0600Date Closed:2011-06-07 14:08:20
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Applications/app_chanisavail
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) Asterisk_ChanIsAvail_BUG.rtf
( 1) sip.conf
Description:cmd ChanIsAvail() under Asterisk Beta 1.4 always returns ${AVAILSTATUS} as "0" regardless of whether or not the phone is in use, when using the 's' flag.  I have tested the phones while on hold, while in conference, and calling each other and I still seem to get the same ${AVAILSTATUS} every time. I have removed the multiple line presences from the Polycom phones and only have Line 1 configured, in case Asterisk was detecting the other lines as "not in use" with no results.  Attached is a copy of my code in extensions.conf and the CLI output.

 I have phone1 and phone2.  From Phone1, I did a ChanIsAvail on phone1, then phone2.  Then from phone2 I did a ChanIsAvail on phone1, then phone2.  Then I placed Phone1 on hold, then from Phone2, I did a chanisavail on phone1, then phone2.

****** ADDITIONAL INFORMATION ******

============EXTENSIONS .CONF====================

[general]
priorityjumping=no
static=yes
writeprotect=yes

[globals]
priorityjumping=no
TRUNK1=Zap/G1
TRUNK2=Zap/G2
TRUNK3=Zap/G3
CALLRECORD=foo
FOO=foo

[sip]

exten => 4001,1,Macro(stdexten|phone1,sip/phone1)
exten => 4002,1,Macro(stdexten|phone2,sip/phone2)

exten => 5001,1,Macro(support|phone1)
exten => 5002,1,Macro(support|phone2)

exten => 5000,1,Answer()
exten => 5000,2,MusicOnHold()

[macro-stdexten]
exten => s,1,Dial(${ARG2},20)                                  ; Ring the interface, 20 seconds maximum
exten => s,2,Goto(s-${DIALSTATUS},1)                           ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
exten => s-NOANSWER,1,Voicemail(u${ARG1})                      ; If unavailable, send to voicemail w/ unavail announce
exten => s-NOANSWER,2,Goto(default,s,1)                        ; If they press #, return to start
exten => s-BUSY,1,Voicemail(b${ARG1})                          ; If busy, send to voicemail w/ busy announce
exten => s-BUSY,2,Goto(default,s,1)                            ; If they press #, return to start
exten => _s-.,1,Goto(s-NOANSWER,1)                             ; Treat anything else as no answer
exten => a,1,VoicemailMain(${ARG1})                            ; If they press *, send the user into VoicemailMain

[macro-support]
;Arg1=Extension
;0 "Unknown", Valid, but unknown state
;1 "Not in use", Not used
;2 "In use", In use
;3 "Busy", Busy
;4 "Invalid", Invalid - not known to Asterisk
;5 "Unavailable", Unavailable (not registred)
;6 "Ringing", "Ring, ring, ring"

exten => s,1,ChanIsAvail(SIP/${ARG1}|s)
exten => s,2,NoOp(Channel ${ARG1} has a status of ${AVAILSTATUS})
exten => s,3,Goto(s-${AVAILSTATUS},1)
exten => s,103,NoOp(Channel ${ARG1} has a status of ${AVAILSTATUS})

;exten => s-1,1,Dial(Sip/${ARG1},60)  ;Channel is available
;exten => s-1,n,Goto(s-${DIALSTATUS}) ;We still want fail over.

exten => s-0,1,NoOp(Made it to ${EXTEN} with code ${AVAILSTATUS})
exten => s-1,1,NoOp(Made it to ${EXTEN} with code ${AVAILSTATUS})
exten => s-2,1,NoOp(Made it to ${EXTEN} with code ${AVAILSTATUS})
exten => s-3,1,NoOp(Made it to ${EXTEN} with code ${AVAILSTATUS})
exten => s-4,1,NoOp(Made it to ${EXTEN} with code ${AVAILSTATUS})
exten => s-5,1,NoOp(Made it to ${EXTEN} with code ${AVAILSTATUS})
exten => _s-.,1,NoOp(WARNING!  We are in extension ${EXTEN} with a code of ${AVAILSTATUS})


============CLI  OUTPUT==========================

Asterisk 1.4.0-beta3, Copyright (C) 1999 - 2006 Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'show license' for details.
=========================================================================
Connected to Asterisk 1.4.0-beta3 currently running on nextgenast (pid = 12498)
Verbosity is at least 99
   -- Executing [5001@sip:1] Macro("SIP/phone1-00713e60", "support|phone1") in new stack
   -- Executing [s@macro-support:1] ChanIsAvail("SIP/phone1-00713e60", "SIP/phone1|s") in new stack
   -- Executing [s@macro-support:2] NoOp("SIP/phone1-00713e60", "Channel phone1 has a status of 0") in new stack
   -- Executing [s@macro-support:3] Goto("SIP/phone1-00713e60", "s-0|1") in new stack
   -- Goto (macro-support,s-0,1)
   -- Executing [s-0@macro-support:1] NoOp("SIP/phone1-00713e60", "Made it to s-0 with code 0") in new stack
   -- Executing [5002@sip:1] Macro("SIP/phone1-00713e60", "support|phone2") in new stack
   -- Executing [s@macro-support:1] ChanIsAvail("SIP/phone1-00713e60", "SIP/phone2|s") in new stack
   -- Executing [s@macro-support:2] NoOp("SIP/phone1-00713e60", "Channel phone2 has a status of 0") in new stack
   -- Executing [s@macro-support:3] Goto("SIP/phone1-00713e60", "s-0|1") in new stack
   -- Goto (macro-support,s-0,1)
   -- Executing [s-0@macro-support:1] NoOp("SIP/phone1-00713e60", "Made it to s-0 with code 0") in new stack
   -- Executing [5001@sip:1] Macro("SIP/phone2-00713e60", "support|phone1") in new stack
   -- Executing [s@macro-support:1] ChanIsAvail("SIP/phone2-00713e60", "SIP/phone1|s") in new stack
   -- Executing [s@macro-support:2] NoOp("SIP/phone2-00713e60", "Channel phone1 has a status of 0") in new stack
   -- Executing [s@macro-support:3] Goto("SIP/phone2-00713e60", "s-0|1") in new stack
   -- Goto (macro-support,s-0,1)
   -- Executing [s-0@macro-support:1] NoOp("SIP/phone2-00713e60", "Made it to s-0 with code 0") in new stack
   -- Executing [5002@sip:1] Macro("SIP/phone2-00713e60", "support|phone2") in new stack
   -- Executing [s@macro-support:1] ChanIsAvail("SIP/phone2-00713e60", "SIP/phone2|s") in new stack
   -- Executing [s@macro-support:2] NoOp("SIP/phone2-00713e60", "Channel phone2 has a status of 0") in new stack
   -- Executing [s@macro-support:3] Goto("SIP/phone2-00713e60", "s-0|1") in new stack
   -- Goto (macro-support,s-0,1)
   -- Executing [s-0@macro-support:1] NoOp("SIP/phone2-00713e60", "Made it to s-0 with code 0") in new stack
   -- Executing [5000@sip:1] Answer("SIP/phone1-00713e60", "") in new stack
   -- Executing [5000@sip:2] MusicOnHold("SIP/phone1-00713e60", "") in new stack
   -- Started music on hold, class 'default', on SIP/phone1-00713e60
[Nov  7 09:16:04] WARNING[28119]: file.c:553 ast_openstream_full: File /var/lib/asterisk/moh/ does not exist in any format
[Nov  7 09:16:04] WARNING[28119]: res_musiconhold.c:246 ast_moh_files_next: Unable to open file '/var/lib/asterisk/moh/': No such file or directory
   -- Stopped music on hold on SIP/phone1-00713e60
   -- Executing [5001@sip:1] Macro("SIP/phone2-00711f40", "support|phone1") in new stack
   -- Executing [s@macro-support:1] ChanIsAvail("SIP/phone2-00711f40", "SIP/phone1|s") in new stack
   -- Executing [s@macro-support:2] NoOp("SIP/phone2-00711f40", "Channel phone1 has a status of 0") in new stack
   -- Executing [s@macro-support:3] Goto("SIP/phone2-00711f40", "s-0|1") in new stack
   -- Goto (macro-support,s-0,1)
   -- Executing [s-0@macro-support:1] NoOp("SIP/phone2-00711f40", "Made it to s-0 with code 0") in new stack
 == Spawn extension (sip, 5000, 2) exited non-zero on 'SIP/phone1-00713e60'
   -- Executing [5000@sip:1] Answer("SIP/phone2-00713e60", "") in new stack
   -- Executing [5000@sip:2] MusicOnHold("SIP/phone2-00713e60", "") in new stack
   -- Started music on hold, class 'default', on SIP/phone2-00713e60
[Nov  7 09:16:09] WARNING[16878]: file.c:553 ast_openstream_full: File /var/lib/asterisk/moh/ does not exist in any format
[Nov  7 09:16:09] WARNING[16878]: res_musiconhold.c:246 ast_moh_files_next: Unable to open file '/var/lib/asterisk/moh/': No such file or directory
   -- Stopped music on hold on SIP/phone2-00713e60
   -- Executing [5002@sip:1] Macro("SIP/phone1-00703b40", "support|phone2") in new stack
   -- Executing [s@macro-support:1] ChanIsAvail("SIP/phone1-00703b40", "SIP/phone2|s") in new stack
   -- Executing [s@macro-support:2] NoOp("SIP/phone1-00703b40", "Channel phone2 has a status of 0") in new stack
   -- Executing [s@macro-support:3] Goto("SIP/phone1-00703b40", "s-0|1") in new stack
   -- Goto (macro-support,s-0,1)
   -- Executing [s-0@macro-support:1] NoOp("SIP/phone1-00703b40", "Made it to s-0 with code 0") in new stack
 == Spawn extension (sip, 5000, 2) exited non-zero on 'SIP/phone2-00713e60'
Comments:By: Joshua C. Colp (jcolp) 2006-11-09 22:06:21.000-0600

I believe we talked about this before but did you try using peers instead of friends? and with call limits? Can you report back with your findings. I think this is related to another bug and think I know what it is.

By: jmls (jmls) 2006-11-20 14:35:09.000-0600

Mercestes: were you able to test with the above sugesstions ?

By: Mercestes D'Moriarty (mercestes) 2006-11-26 21:08:21.000-0600

I did try with Peers instead of Friends and with Call Limits and I returned the exact same errant results.  I tested this with everything set as Peers prior to filing the bug report.  I also elminated the "multiple presences" of the phones to make them single line phones so Asterisk would not errantly detect another "presence" as "Available."

 I had to make this function work by Setting the call limit to one with only one available line and doing a Goto(${DIALSTATUS}) instead of using the "ChanIsAvail" function.

By: Joshua C. Colp (jcolp) 2006-11-27 11:03:17.000-0600

Shuffled this bug over to murf since it is related to the devicestate stuff he is working on.

By: Richard Miller (ulogic) 2006-12-04 21:40:36.000-0600

I also use ChanIsAvail in my dialplans.  Some employees have multiple SIP extensions, for example, office desk, home phone, and WiFi when roaming about the office.  I send callers directly to voice mail with the busy prompt if any one of the extensions is in use.

There are two new device states in this 1.4 beta version including
#define AST_DEVICE_ONHOLD 8

What I have found is once you put a SIP call on hold, the device status becomes 8 and gets stuck there even after hanging up the call.  Zaptel channels appear to be toggling between 0 and 2, but SIP channels do not.

By: Steve Murphy (murf) 2006-12-04 22:23:04.000-0600

First of all; please try out the 7433 branch at

asterisk/team/group/bug7433

It's based on 1.4.

Also to remember, before you start, to add this to the [general] section of your sip.conf:

limitpeersonly=yes

this particular version didn't require a call_limit setting to work; try it out and see if it clears things up. If not, please collect your logfiles and attach them to this bug.

By: Anthony LaMantia (alamantia) 2006-12-15 18:58:25.000-0600

any updates on this issue?

By: Ronald Chan (loloski) 2007-01-20 07:45:04.000-0600

Mercestes:

First of all; please try out the 7433 branch at

asterisk/team/group/bug7433

It's based on 1.4. This branch with murf is working fine with me, since the patch  emerge.If you could visit bug ASTERISK-7238 there's an objection with it due to performance hit in realtime, our millage may vary but it's damn worth a try.

By: Corey Frang (gnarf) 2007-01-20 18:59:03.000-0600

perhaps a simpler solution exists:

http://bugs.digium.com/view.php?id=8859

By: Joshua C. Colp (jcolp) 2007-02-16 21:38:52.000-0600

Since this issue isn't really moving and it just seems to be the same ol' devicestate/sip issue (will it ever end) I'm closing this out for now.