[asterisk-users] Is order of channels shown by Function_CHANNELS consistently newest first?

Jonathan H lardconcepts at gmail.com
Fri Oct 26 13:19:01 CDT 2018

After originating a PJSIP call, I need to get the channel for that call, so
I can end it later in a hangup handler.
So I use this:


In this bit of dialplan:

    same => n,Originate(PJSIP/0203123456 at voipfone-205
    same => n,Verbose(1,***CHANNELS ARE ${CHANNELS()})
    same => n,SET(GLOBAL(chan)=${CHANNELS(PJSIP\/voipfone-205-(.*))})

Now, of course, I get more than one channel shown, like this:

***CHAN WE WANT IS PJSIP/voipfone-205-00000249 PJSIP/voipfone-205-0000024c

Assuming I use CUT to trim out the first in the list, can we ALWAYS be
absolutely sure that the channel just created by Originate is the highest
numbered/first in list?

Otherwise, I'm wondering if there's a reliable way to get the channel
created by originate, when there may be many other active channels on the
system, too.

In case anyone's wondering, I'm using it so that when there is only one
party left in a conference, it'll clear down the newly created external
For which I need the outgoing name, of course...

    same => n,GotoIf($["${CONFBRIDGE_INFO(parties,1234)}" = "1"]?hangchan)
    same => n,Return()
    same => n(hangchan),SoftHangup(${GLOBAL(chan)})
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20181026/4f9f51fd/attachment.html>

More information about the asterisk-users mailing list