Multiple Phones When One Is Unregistered

Home » Asterisk Users » Multiple Phones When One Is Unregistered
Asterisk Users 24 Comments

I have an extension that looks like this:

exten => 5555551111,1,Verbose(Door buzzer calling)
same => n,Dial(SIP/user1&SIP/user2&SIP/user3)

The idea is that any of the three users can answer the phone to let someone in. The problem is that if, say, user2 unplugs his phone then the call immediately goes to his voice mail and the other two do not have the ability to open the door.

Is there any way to direct only to phones in a list that are currently registered? I am sure that I can write a rather convoluted extension to check for registrations and create a dial command but I am hoping that there is an easier way so that I can create these types of extensions for other clients easily as well as being able to add and remove destinations quickly.

Cheers.

24 thoughts on - Multiple Phones When One Is Unregistered

  • Dear D’Arcy J.M. Cain and asterisk friends,

    To my opinion, you need a queue with dynamic agents.

    SIP/userX subscribes and checkouts manually, or better SIP/userX adds to the specific queue at the moment she or he registers to the system. I know how to do the former, but I would like to know about the latter. If someone could comment on that, I would highly appreciate.

  • D’Arcy J.M. Cain wrote:

    The Asterisk behavior is such that even if one of those users are unregistered the other two will continue to be called. Is something upstream from Asterisk doing the voicemail?

  • The dialplan below cannot go to voicemail, either something else is going on or the dialplan below is not the actual dialplan. Calls only go to voicemail when the dialplan runs the VoiceMail application.

    Paste the Asterisk console output of a call showing the problem, maybe someone can help.

  • There is nothing in that dialplan snippet you provided that would send anything to voicemail. In fact, if you used that snippet, it would give the exact behaviour you describe yourself as wanting!

    Here’s a protip for you: It’s *not* a massive corporate secret, which phone will ring when somebody dials what number. Obfuscating your real dialplan like that just makes it harder for other people to help you.

  • Of course not. It’s the individual extensions that have voice mail. I
    have a similar problem when one of those destinations is a cell phone but I know that there is no Asterisk solution for that problem. If the cell phone answers and goes into the cell phone voice mail I am screwed. I can’t fix that unless I also run the cell phone company.

    In this case the extensions are all set up in the same asterisk server. Here is an example.

    [user1](client-phone)
    secret=NotTheRealSecret callerid=John Doe <5555551212>
    mailbox=user1@VoiceMail context=pbxout-19212

    And here is the extension that calls it. Sorry about the wrapping.

    user1,1,Verbose(0,Entering extension user1)
    same => n,GotoIf($[“${DEVICE_STATE(SIP/9999906549)}” “UNAVAILABLE”]?DialCell)
    same => n(DialWifi),Verbose(0, ${CALLERID(all)} Calling ${EXTEN} and SoftPhone)
    same => n,Dial(SIP/user1&SIP/9999906549,30)
    same => n,Goto(VoiceMail)

    same => n(DialCell),GotoIf($[“x7165550000” = “x”]?DialDesk)
    same => n,GotoIf($[“${CALLERID(ani)}” = “7165550000”]?DialDesk)
    same => n,Verbose(0,${CALLERID(all)} Calling “${EXTEN}” and cell
    “7165550000”)
    same => n,Dial(SIP/user1&SIP/thinktel/7165550000,30)
    same => n,Goto(VoiceMail)

    same => n(DialDesk),Verbose(0,${CALLERID(all)} Calling ${EXTEN})
    same => n,Dial(SIP/user1,30)

    same => n(VoiceMail),Set(CDR(userfield)=VoiceMail)
    same => n,Set(_ACCOUNT=user1)
    same => n,VoiceMail(user1@VoiceMail,u)
    same => n,Hangup()

    It’s a complicated extension but I believe that the following is the essential part.

    user1,1,Verbose(0,Entering extension user1)
    same => n,Dial(SIP/user1,30)
    same => n,VoiceMail(user1@VoiceMail,u)
    same => n,Hangup()

    Here is what the log shows. I can’t put the unregistered user back at the moment. Perhaps I can do it overnight when no one is going to the building.

    [Aug 23 10:20:55] WARNING[-1][C-0001fee7] app_dial.c: Unable to create channel of type ‘SIP’ (cause 20 – Subscriber absent)

    I am assuming that the voice mail is for the absent (unregistered) user.

    Other than sanitizing the buzzer phone number and the user names this is the full extension for the buzzer.

  • I will give you the benefit of the doubt and assume that you are not trying to patronize me.

    All I did was sanitize the buzzer phone number and the names of the users. Other than that the above is the complete dialplan. See my other message for details of those extensions. I didn’t think that there was anything relevant in that but I could be wrong.

  • You should set your verbosity to 3 and then reproduce the call and paste the CLI output. It is pointless to troubleshoot without the CLI
    output. The warning is expected when the phone is offline and does not cause the issue you are experiencing. It almost looks like Local/
    channels are involved, but we’ll know more once we see the CLI output.

  • I can’t do it during the day but I will try overnight. Can’t be tonight as I have a gig (120 Diner at 120 Church if you happen to be in Toronto) but I will try later this week.

    What do you mean by “Local channels?” They are local to the server. Do you mean that I might be in the wrong context?

  • That looks good and is easy to add and delete from the list. I will give this a try one night this week. Not sure what that last line would do if all of the phones are off but if they are the buzzer won’t be answered anyway.

    Thanks.

  • Failed. I checked the online docs and the syntax seems to be correct but I get this:

    [Aug 31 21:52:00] WARNING[-1][C-0001fed5] pbx.c: No application
    ‘ExecIf’ for extension (unauthenticated, 5555551111, 3)

    Is there a module that I need to load?

    In case it matters I am running Asterisk 11.23.0 on NetBSD 7.0.

  • Set is a function, not an application. ExecIF executes an application. I’m a bit confused by this whole topic. The dialplan snippet in the original email

    should have rung the phones forever as long as one phone was active and not forwarding or DNDing.

    Mark

  • I wondered about that but the docs are not very explicit on the subject and I thought that the other poster was suggesting something that he had used/tested.

    So does the Dial command go directly to the registered device or does it use the extension? I was assuming that it was going to the extension’s voice mail if it wasn’t there but that’s in the extension dialplan and I suspect that the extension is irrelevant and only the SIP registration matters. That would be a good thing since many extensions also ring the user’s cell phone and that would be annoying if they were at home when someone came to the office door.

    Perhaps my problem was that one of the users was removed from sip.conf but their phone was still in the above plan. For example, user2 leaves the company, is removed from sip.conf but we forgot to remove him from the door buzzer extension. That might give me the behaviour that I was seeing.

    I think I have enough information now to analyze this problem if it happens again. Thanks for the help.

  • It looks like this doesn’t matter any more but I do wonder why I don’t have that command.

    # asterisk -x “core show application ExecIf”
    Your application(s) is (are) not registered Command ‘core show application ExecIf’ failed.

    What module am I missing?

  • Yes, that’s why you provide the technology part (SIP/, IAX/, DAHDI/)

    If the target device has a forward configured, I believe Asterisk will dutifully ring the forward number like it was told, but could be wrong.

    Otherwise, it’ll only go to voicemail, in asterisk, if you tell it to in the dialplan. Could it be going to voicemail on a forward somewhere?

    In my experience, that too should not be a problem. I’ve got the same dial command structure, ringing multiple SIP/extensions in one dial command. I have some instances where the SIP entry in sip.conf no longer exists, and some instances where the device is not registered, and asterisk just displays a warning and continues on. I don’t think so. At least I don’t see that.

    Mark

  • In article <20160901070151.10ae4f26@imp>, D’Arcy J.M. Cain wrote:

    The ExecIf command is provided in the module app_exec, which is usually located at /usr/lib/asterisk/modules/app_exec.so

    Maybe you had turned off app_exec in the menuconfigi when building, or maybe your modules.conf has a noload => app_exec.so

    Cheers Tony

  • What about doing this?

    exten => 5555551111,1,Verbose(Door buzzer calling)
    same => n,Set(toRing=)
    same => n,Set(toRing=${toRing}${IF($[“${DEVICE_STATE(SIP/user1)}” = “NOT IN USE”]?&SIP/user1:)})
    same => n,Set(toRing=${toRing}${IF($[“${DEVICE_STATE(SIP/user2)}” = “NOT IN USE”]?&SIP/user2:)})
    same => n,Set(toRing=${toRing}${IF($[“${DEVICE_STATE(SIP/user3)}” = “NOT IN USE”]?&SIP/user3:)})
    same => n,Dial(${toRing:1}) ;to remove the first &

    Chad

  • The dial application dials devices not extensions. The only way to
    “dial” an extension from the dialplan is to use chan_local.

  • If you’ve given the Dial() command the SIP/user1 format, it will attempt to dial directly to the SIP device/phone/endpoint you specify. If you specify SIP/user1&SIP/user2&… it attempts to dial directly to all of them simultaneously, and the first one which picks up, gets the call
    (the dialouts to the others are dropped when the first one answers).

    To the best of my knowledge there is *no* automatic fallback to the Asterisk voicemail which might be associated with one or more of these SIP users.

    The usual way that you’d get to Asterisk voicemail, is if your dialplan catches the error which would result from Dial() if none of the users is available and answers, and explicitly calls the Voicemail() app.

    Things can become more complicated in a couple of situations:

    (1) If one of the SIP users you specify isn’t actually a SIP
    endpoint device, but is a SIP identity on another system (PBX
    or VoIP provider or etc.), then you really don’t have any control
    over how that endpoint would handle situations where the called
    user isn’t available. The endpoint might answer with *its*
    voicemail, immediately.

    (2) If you were to dial a Local/ destination rather than a SIP/
    destination, then that dialing operation *is* run back through
    your dialplan, and it might divert the call to voicemail instantly.

    The easiest solution to each of these is “Don’t do that”. Don’t multi-dial to anything other than SIP (or IAX) endpoints which are real, physical devices that either ring (if they’re connected) or fail to respond or reject the call (if they aren’t available). Don’t multi-dial to any SIP device which implements its own internal
    “voicemail” feature (e.g. has an answering machine attached).

    I do what you’re thinking of all the time. On my Asterisk setup, one incoming PSTN number goes to an extension which multi-dials about half-a-dozen of my SIP softphones. No matter which tablet or PC I happen to be using, if I’m running the SIP softphone app, it’ll ring.

    The only time the call fails from this dial is if none of the SIP devices answer. I could route to Asterisk voicemail in this case, but I don’t bother – Asterisk simply rejects the call with a no-answer or not-available status, the VoIP provider fails the call, and Google Voice (which is where the original number is anchored) sends the call to its own voicemail system and I get an email.

    The only down-side to this is that the Asterisk log gets a bunch of “SIP call failed” status messages each time this happens – one for each dialed SIP user that wasn’t “on the net” at the time. This isn’t a problem for me in practice.

    Correct.

  • Another option is what I’ve had happen recently. I have my main number dial all the phones in my house, including an old Cisco 7905 that on busy or no answer would send back a 302 redirect to extension 8000 –
    VoiceMail. To make matters worse inbound callers would be dumped into VoiceMail as though they’d entered it from internally, rather than external.

    While I tried various different ways on the Cisco to stop that behaviour, I found the only solution was to tell the Dial() command to ignore the 302 by adding the i flag. Problem solved.

    Cheers, Andrew


    Andrew Ruthven, Wellington, New Zealand MIITP, ITCP

    At work: andrew.ruthven@catalyst.net.nz At home: andrew@etc.gen.nz Cloud  : NZs only real cloud – https://catalyst.net.nz/cloud GPG fpr: C603 FC4E 600F 1CEC D1C8  D97C 4B53 D931 E4D3 E863
    LCA2017: The Future of Open Source, Hobart, AU – http://linux.conf.au