Summary:ASTERISK-16313: AVAILSTATUS set to 20
Reporter:philipp2 (philipp2)Labels:
Date Opened:2010-07-02 08:22:28Date Closed:2011-08-30 16:52:58
Versions:Frequency of
Description:For a SIP peer (Realtime, usually not registered (but can be) ChanIsAvail can sometimes return "20" in AVAILSTATUS. Correct values for AVAILSTATUS are, however, all < 10.

In the case of AVAILSTATUS=20 both AVAILCHAN and AVAILORIGCHAN are always empty.
Hostnames can either be FQDN or IP.

Has also happend on 1.4.29 and 1.4.31.


Also reported by another user in March 2010:

ChanIsAvail returns 20 for ${AVAILSTATUS}. What does this '20' mean ??

exten => 1,n,ChanIsAvail(SIP/sin10)
exten => 1,n,NoOp(chanisavail == ${AVAILSTATUS})

[Mar  4 15:10:16]     -- Executing [1 at sin:7]
ChanIsAvail("IAX2/testlocal-14088", "SIP/sin10") in new stack
[Mar  4 15:10:16]     -- Executing [1 at sin:8]
NoOp("IAX2/testlocal-14088", "chanisavail == 20") in new stack

What does it mean when ChanIsAvail returns '20' ???

This is what inside /usr/src/asterisk- :

/*! \brief Device state strings for printing */
static const char *devstatestring[] = {
       /* 0 AST_DEVICE_UNKNOWN */      "Unknown",      /*!< Valid, but
unknown state */
       /* 1 AST_DEVICE_NOT_INUSE */    "Not in use",   /*!< Not used */
       /* 2 AST_DEVICE IN USE */       "In use",       /*!< In use */
       /* 3 AST_DEVICE_BUSY */         "Busy",         /*!< Busy */
       /* 4 AST_DEVICE_INVALID */      "Invalid",      /*!< Invalid -
not known to Asterisk */
       /* 5 AST_DEVICE_UNAVAILABLE */  "Unavailable",  /*!< Unavailable
(not registered) */
       /* 6 AST_DEVICE_RINGING */      "Ringing",      /*!< Ring, ring,
ring */
       /* 7 AST_DEVICE_RINGINUSE */    "Ring+Inuse",   /*!< Ring and in
use */
       /* 8 AST_DEVICE_ONHOLD */       "On Hold"       /*!< On Hold */

Comments:By: Paul Belanger (pabelanger) 2010-07-02 09:50:28

We require a complete debug log to help triage the issue.

This document will provide instructions on how to collect debugging logs from an Asterisk machine for the purpose of helping bug marshals troubleshoot an issue:


By: philipp2 (philipp2) 2010-07-02 12:32:02

I know, but this is a) on a permanently used production system with quite a lot of concurrent calls, and more importantly I have b) not yet found a way to reproduce this. Unfortunately the logs that I have available do not provide the level of details the link above requests.

By: Joe Cracchiolo (jjcinaz) 2010-07-03 12:33:35

The application is actually documented to return "both a device state and a cause code".  In this case, the 20 is a cause code.  This behaviour is probably bad since cause codes and device states overlap in name-space (i.e. they both have values from 0 through 9 which collide).  

In this example, the 20 = AST_CAUSE_SUBSCRIBER_ABSENT, but if the app returned a value of 6, that could mean AST_CAUSE_CHANNEL_UNACCEPTABLE or AST_DEVICE_RINGING.

Changing this may break dial plans dependant on this behavior, but it IMHO it should get changed to return the CAUSE in a different variable.  Whomever added the CAUSE code returned could comment more on the desired behavior.

By: philipp2 (philipp2) 2010-07-03 12:46:56

Thank you for pointing this out - I wonder how I missed that documentation, maybe because the documentation was updated after the last time I fully read it.

Indeed, mixing the type of the result is very confusing, also because we do not really do a Dial() and therefore I wonder what the (reduced) list of possible cause codes looks like.

By: philipp2 (philipp2) 2010-07-07 19:50:32

Here is a way to get AVAILSTATUS=20 by attempting a call to non-existent SIP/xyz:
"chan_sip.c:3087 create_addr: No such host: xyz"

By: Michael Spiceland (mspiceland) 2011-08-30 16:52:42.935-0500

Per the Asterisk maintenance timeline page at http://www.asterisk.org/asterisk-versions maintenance (bug) support for the 1.4 and 1.6.x branches has ended. For continued maintenance support please move to the 1.8 branch which is a long term support (LTS) branch. For more information about branch support, please see https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions.  After testing with Asterisk 1.8, if you find this problem has not been resolved, please open a new issue against Asterisk 1.8.