Summary:ASTERISK-04390: ChanIsAvail not working with SIP
Reporter:tgj (tgj)Labels:
Date Opened:2005-06-10 04:20:41Date Closed:2011-06-07 14:10:13
Versions:Frequency of
Environment:Attachments:( 0) sipdebug.txt
Description:ChanIsAvail seems to always indicate that a SIP channel is available, this is a trace from CLI:

   -- Executing ChanIsAvail("SIP/201-7c2a", "SIP/211") in new stack
   -- Executing SetVar("SIP/201-7c2a", "OUTGOING-MOB=SIP/211/") in new stack
   -- Executing NoOp("SIP/201-7c2a", "SIP/211-1f24") in new stack
   -- Executing Goto("SIP/201-7c2a", "dial-phone-out|61277000|1") in new stack
   -- Goto (dial-phone-out,61277000,1)
   -- Executing Dial("SIP/201-7c2a", "SIP/211/61277000|120|wWtT") in new stack
   -- Called 211/61277000
   -- Got SIP response 503 "Service Unavailable" back from
   -- SIP/211-24fd is circuit-busy
Comments:By: Michael Jerris (mikej) 2005-06-10 06:22:53

Chanisavail is not going to return if the channel is available by the time you get to the dial, it should be returning the state of the channel when you are actually running the chanisavail app.  Can you verify that it returns true when you manually make the channel unavailable (unplug the phone or somthing)?  Also we need config examples, and a verbose w/ sip debug could be helpful on this as well

By: tgj (tgj) 2005-06-10 07:37:48

The channel SIP/211 is unavailable all the time as I am on a call when I perform this test.

This is the config:

callerid=Thorben Jensen privat <211>
username=Thorben Jensen privat

By: Michael Jerris (mikej) 2005-06-10 07:43:49

somthing still does not look right here, you are sending ext 61277000 too the phone?  As I said, please provide a sip debug on this.  Also, what kind of phone is it.

By: tgj (tgj) 2005-06-10 08:24:30

SIP/211 is connected to a Sipura SPA-3000 FXO port. To the FXO port is connected a GSM gateway, that is why I am sending 61277000 to the gw.

I have uploaded a sip debug file.

By: Michael Jerris (mikej) 2005-06-10 09:08:53

also, can I see the extensions.conf snippet that is being run here.

By: tgj (tgj) 2005-06-10 09:16:17

exten => _X.,1,ChanIsAvail(SIP/211)
exten => _X.,2,SetVar(OUTGOING-MOB=SIP/211/)
exten => _X.,3,noop(${AVAILCHAN})
exten => _X.,4,Goto(dial-phone-out,${EXTEN},1)
exten => _X.,102,SetVar(OUTGOING-MOB=IAX2/<username>:<password>@
exten => _X.,103,Goto(dial-phone-out,${EXTEN},1)

By: tgj (tgj) 2005-06-25 00:36:18

Any progress on this issue?

By: Olle Johansson (oej) 2005-06-25 04:36:43

Well, from Asterisk's point of view, the channel is available. Asterisk has no knowledge about the state of the Sipura and whatever the Sipura can do out there in the wild network.

By: tgj (tgj) 2005-06-26 00:23:13

Hi oej,

I am not sure I understand. Does the sipura not behave like any other SIP phone and why would Asterisk not know that the channel is busy?

By: Michael Jerris (mikej) 2005-06-26 00:55:47

I beleive the situation in this case is that the channel is available, but the sipura is returning service unavailable only when you attempt to make the call.  As we discussed on IRC, this could be related to the number you are trying to call.  I am not sure why you would be getting a 503 in that case.  Can you please do more testing as to dialing to whahtever the sipiura is calling using an analog phone, and see in the sipura documentation under what situations it returns 503.  I do beleive this is not an asterisk problem, but I would like to be sure.

By: tgj (tgj) 2005-06-26 01:42:31

I have connected the Sipura as SIP/211 to asterisk and to the Sipuras FXO channel I have connected a GMS gateway. Now I make a call to SIP/211/61277000 that will make the GSM gateway call my GSM phone. While I am on the GSM phone I try to make another call to SIP/211 and ChanIsAvail will report that its available which is obviously wrong as I am still speaking on the GSM phone through SIP/211.
I hope this makes sense.

By: DanFer (danfernandez00) 2005-07-10 14:46:53

I have the same problem as tgj. I have several Sipuras 3000s where ChanisAvail and CheckGroup don't work. Basically if I am on a call on the FXO channel (connected to the PSTN) and I tried to place another call to that same channel I generally get 503 Service unavailable, as it should. However, every now and then (let's say 20-30% of the time) Asterisk's bridges boths calls. Once I figured what the problem was I tried to use chanisavail or CheckGroup but I am seen the same result.

By: Kevin P. Fleming (kpfleming) 2005-07-11 21:45:53

There is no way that any behavior in chan_sip can influence the results of CheckGroup; group counting of channels is done outside of any channel code. If CheckGroup did not work for you, then you did not implement it properly :-)

ChanIsAvail is _not_ a solution to tell you conclusively whether the channel is busy or not, it is primarily to tell you whether it would be _possible_ to send a call there. Whether that call would end up being accepted or not is entirely up to the peer that we send the call to, and they could easily reject the call even though they do not appear to be 'busy'.

I believe that if you want to use ChanIsAvail to determine whether the SIP peer is known and registered, it will work fine. If you want to use it for limiting simultaneous calls to the peer, it will not work reliably for you.

By: Michael Jerris (mikej) 2005-07-20 18:55:50

This appears to be a configuration error.. chanisavail does not do what you want it to do here... a better solution would be to use app_groupcount to keep track of number of calls going to that channel.  More info can be found here:  http://www.voip-info.org/tiki-index.php?page=Asterisk+cmd+SetGroup.