Bridging an existing conference to a new call


#1

For the first caller to a conference, I want to dial out and bridge that conference to a new PJSIP external call.

For the next callers, I just want them to join the local Asterisk conference.

After the last caller leaves the conference, I want to hangup the call it initiated. Most of this works, but there are two problems - after the dial string is done sending, no further audio flows between the Confbridge conference and the external call.

Secondly, I understand that I need the name of the “dialling out” channel:

https://wiki.asterisk.org/wiki/display/AST/Pre-Bridge+Handlers

This application sets the following channel variables:
DIALEDPEERNAME - The name of the outbound channel that answered the call.

But that variable is just empty. Can anyone please suggest where I might be going wrong here, and how to complete this? Thank you!

[bcab-dial-zoom]
exten => s,1,Answer()
same => n,Dial(PJSIP/0203456789@voipfone-201,,U(bcab-send-dtmf))

[bcab-send-dtmf]
    exten => s,1,Wait(1)
    same => n,Verbose(1,***Dialled channel is ${DIALEDPEERNAME})
    same => n,Set(dialedname=${DIALEDPEERNAME})
    same => n,SendDTMF(WW123456#WWWWW#WWWWW)
    same => n,Playback(technical-support)
    same => n,SendDTMF(#)

    same => n,SET(GOSUB_RESULT=GOTO:bcab-bridge-conference^s^1)
    same => n,Return()   

[bcab-bridge-conference]
exten => s,1,Verbose(1,*** Entered bcab-bridge-conference)
    same => n,Answer()
    same => n,ConfBridge(1234) 
    same => n,Wait(55)
    same => n,Hangup()

Is order of channels shown by Function_CHANNELS consistently newest first?
#2

try using __ to set the variable


#3

***Dialled channel is ${DIALEDPEERNAME}

Unfortunately, I don’t think that’ the side of the equation that the problem lies on.

same => n,Verbose(1,***Dialled channel is ${DIALEDPEERNAME})

just results in

***Dialled channel is


#4

Try throwing in a Dumpchan() between the Wait and the Verbose and see what variables you have to work with.


#5

Ok got it,I found an useful information from @mjordan on this link that it worth to read it https://asteriskfaqs.org/2016/09/17/asterisk-users/ast-13112-bridgepeer-variable-empty.html

Im not sure but I assume as U option Execute via Gosub the routine x for the called channel before connecting to the calling channel, DIALEDPEERNAME is empty because the variable is created when the outbound channel that answered the call.


#6

OK, thanks both.

So it looks like the only extra variable I have to use after the dial is:

DIALEDPEERNUMBER=02031234567@voipfone-201

So now I have the problem that I do not know what the channel ID that has been created so I can hangup when the last caller has left the conference.

And I still have the issue where it doesn’t seem to bridge the CONFBRIDGE conference to the newly dialed PJSIP channel.

I think I am missing something very fundamental here, but info about CONFBRIDGE seems spread far and wide with few solid examples.

Can anyone suggest any ideas please? Thank you!


#7

Day 4 - nothing seems to work as documented.

I have updated my dialplan as follows. It makes the outgoing call, the remote end of the new call hears what they should, but 5 seconds after same => n,ConfBridge(1234) the new call is cleared down.

Let’s break this down and look at some dialplan and logs:

[bcab-local-conference]    
exten => s,1,Answer()
    same => n,Set(CONFBRIDGE(user,announce_join_leave)=no)
    same => n,Verbose(1,***NUMBER IN CONFERENCE IS ${CONFBRIDGE_INFO(parties,1234)})
    same => n,GotoIf($["${CONFBRIDGE_INFO(parties,1234)}" = "0"]?bcab-dial-zoom,s,1)
    same => n,ConfBridge(1234)  

[bcab-dial-zoom]
exten => s,1,Answer()
same => n,Dial(PJSIP/0123456789@voipfone-201,,U(bcab-send-dtmf)L(10000))
; the time limit (L) above does not seem to work

[bcab-send-dtmf]
    exten => s,1,Wait(1)
    same => n,SendDTMF(WW12345#WWWWW#WWWWW)
    same => n,Playback(technical-support)
    same => n,SendDTMF(#)
    same => n,SET(GOSUB_RESULT=GOTO:bcab-bridge-conference^s^1)
    same => n,Return()   

[bcab-bridge-conference]
exten => s,1,Verbose(1,*** Entered bcab-bridge-conference)
    same => n,Answer()
    same => n,Set(__BCAB_Outgoing_Conf_Channel=${DIALEDPEERNAME})
    same => n,Verbose(1,***Dialled channel after ANSWER in bcab-bridge-conference is ${BCAB_Outgoing_Conf_Channel})

    same => n,ConfBridge(1234) 
    ; nothing happens on the console after here, and the outgoing call is terminated
    same => n,Verbose(1,***DUMPING CHANNEL VARS after CONFBRIDGE in bcab-bridge-conference)
    same => n,Dumpchan() 
    same => n,Wait(55)
    same => n,Hangup()

Here’s what I see on the console:

-- Executing [13@6001:1] Answer("PJSIP/6001-0000003d", "") in new stack
       > 0x7efdf401df80 -- Strict RTP learning after remote address set to: 90.196.205.73:4010
    -- Executing [13@6001:2] Set("PJSIP/6001-0000003d", "CALLERID(name)=bcab") in new stack
    -- Executing [13@6001:3] Goto("PJSIP/6001-0000003d", "bcab-local-conference,s,1") in new stack
    -- Goto (bcab-local-conference,s,1)
    -- Executing [s@bcab-local-conference:1] Answer("PJSIP/6001-0000003d", "") in new stack
    -- Executing [s@bcab-local-conference:2] Set("PJSIP/6001-0000003d", "CONFBRIDGE(user,announce_join_leave)=no") in new stack
    -- Executing [s@bcab-local-conference:3] Verbose("PJSIP/6001-0000003d", "1,***NUMBER IN CONFERENCE IS 0") in new stack
 ***NUMBER IN CONFERENCE IS 0
    -- Executing [s@bcab-local-conference:4] GotoIf("PJSIP/6001-0000003d", "1?bcab-dial-zoom,s,1") in new stack
    -- Goto (bcab-dial-zoom,s,1)
    -- Executing [s@bcab-dial-zoom:1] Answer("PJSIP/6001-0000003d", "") in new stack
    -- Executing [s@bcab-dial-zoom:2] Dial("PJSIP/6001-0000003d", "PJSIP/0123456789@voipfone-201,,U(bcab-send-dtmf)L(10000)") in new stack
    -- Setting call duration limit to 10.000 seconds.
    -- Called PJSIP/0123456789@voipfone-201
    -- PJSIP/6001-0000003d requested media update control 26, passing it to PJSIP/voipfone-201-0000003e
       > 0x7efdf401df80 -- Strict RTP switching to RTP target address 90.196.205.73:4010 as source
       > 0x7efdf402db30 -- Strict RTP learning after remote address set to: 46.31.X.X:51912
    -- PJSIP/voipfone-201-0000003e is making progress passing it to PJSIP/6001-0000003d
    -- PJSIP/voipfone-201-0000003e is making progress passing it to PJSIP/6001-0000003d
       > 0x7efdf402db30 -- Strict RTP switching to RTP target address 46.31.X.X:51912 as source
       > 0x7efdf401df80 -- Strict RTP learning complete - Locking on source address 90.196.205.73:4010
    -- PJSIP/voipfone-201-0000003e answered PJSIP/6001-0000003d
    -- PJSIP/voipfone-201-0000003e Internal Gosub(bcab-send-dtmf,s,1) start
    -- Executing [s@bcab-send-dtmf:1] Wait("PJSIP/voipfone-201-0000003e", "1") in new stack
       > 0x7efdf402db30 -- Strict RTP learning complete - Locking on source address 46.31.X.X:51912
    -- Executing [s@bcab-send-dtmf:2] SendDTMF("PJSIP/voipfone-201-0000003e", "WW2222397064#WWWWW#WWWWW") in new stack
    -- Executing [s@bcab-send-dtmf:3] Playback("PJSIP/voipfone-201-0000003e", "technical-support") in new stack
    -- <PJSIP/voipfone-201-0000003e> Playing 'technical-support.alaw' (language 'en_GB')
    -- Executing [s@bcab-send-dtmf:4] SendDTMF("PJSIP/voipfone-201-0000003e", "#") in new stack
    -- Executing [s@bcab-send-dtmf:5] Set("PJSIP/voipfone-201-0000003e", "GOSUB_RESULT=GOTO:bcab-bridge-conference^s^1") in new stack
    -- Executing [s@bcab-send-dtmf:6] Return("PJSIP/voipfone-201-0000003e", "") in new stack
  == Spawn extension (fromvoipfone201, , 1) exited non-zero on 'PJSIP/voipfone-201-0000003e'
    -- PJSIP/voipfone-201-0000003e Internal Gosub(bcab-send-dtmf,s,1) complete GOSUB_RETVAL=
    -- Executing [s@bcab-bridge-conference:1] Verbose("PJSIP/6001-0000003d", "1,*** Entered bcab-bridge-conference") in new stack
 *** Entered bcab-bridge-conference
    -- Executing [s@bcab-bridge-conference:2] Answer("PJSIP/6001-0000003d", "") in new stack
    -- Executing [s@bcab-bridge-conference:3] Set("PJSIP/6001-0000003d", "__BCAB_Outgoing_Conf_Channel=PJSIP/voipfone-201-0000003e") in new stack
    -- Executing [s@bcab-bridge-conference:4] Verbose("PJSIP/6001-0000003d", "1,***Dialled channel after ANSWER in bcab-bridge-conference is PJSIP/voipfone-201-0000003e") in new stack
 ***Dialled channel after ANSWER in bcab-bridge-conference is PJSIP/voipfone-201-0000003e
    -- Executing [s@bcab-bridge-conference:5] ConfBridge("PJSIP/6001-0000003d", "1234") in new stack
    -- Channel CBAnn/1234-00000006;2 joined 'softmix' base-bridge <a8ffe6d4-1b3d-4fb4-aa3a-cd691a0d9063>
    -- <PJSIP/6001-0000003d> Playing 'conf-onlyperson.alaw' (language 'en_GB')
    -- <PJSIP/6001-0000003d> Playing 'confbridge-join.alaw' (language 'en_GB')
    -- <CBAnn/1234-00000006;1> Playing 'confbridge-join.gsm' (language 'en')
    -- Channel PJSIP/6001-0000003d joined 'softmix' base-bridge <a8ffe6d4-1b3d-4fb4-aa3a-cd691a0d9063>

At this point after a few seconds, the called channel (PJSIP/voipfone-201-0000003a) hears a “call ended” signal. Nothing is shown on the console.
The call never lasts longer than 19 seconds.

When I turn psjip debugging on, this is what I see:

  == Spawn extension (fromvoipfone201, , 1) exited non-zero on 'PJSIP/voipfone-201-00000003'
    -- PJSIP/voipfone-201-00000003 Internal Gosub(bcab-send-dtmf,s,1) complete GOSUB_RETVAL=
<--- Transmitting SIP request (459 bytes) to UDP:46.31.X.X:5060 --->
BYE sip:0123456789@46.31.X.X SIP/2.0
Via: SIP/2.0/UDP 139.59.X.X:5060;rport;branch=z9hG4bKPja0f593d3-6a83-4fb6-800d-bbc2e54fbafe
From: <sip:30123456*201@sip.voipfone.net>;tag=e23b6c6b-da93-499b-9801-52955049a48c
To: <sip:0123456789@sip.voipfone.net>;tag=VF38b373b19e51e7a867614baf2245
Call-ID: 05bb5474-41e1-4164-9a9b-a1fac23ce847
CSeq: 14724 BYE
Reason: Q.850;cause=16
Max-Forwards: 70
User-Agent: Asterisk PBX 16.0.0
Content-Length:  0


    -- Executing [s@bcab-bridge-conference:1] Verbose("PJSIP/6001-00000002", "1,*** Entered bcab-bridge-conference") in new stack
 *** Entered bcab-bridge-conference
    -- Executing [s@bcab-bridge-conference:2] Answer("PJSIP/6001-00000002", "") in new stack
    -- Executing [s@bcab-bridge-conference:3] Set("PJSIP/6001-00000002", "__BCAB_Outgoing_Conf_Channel=PJSIP/voipfone-201-00000003") in new stack
    -- Executing [s@bcab-bridge-conference:4] Verbose("PJSIP/6001-00000002", "1,***Dialled channel after ANSWER in bcab-bridge-conference is PJSIP/voipfone-201-00000003") in new stack
 ***Dialled channel after ANSWER in bcab-bridge-conference is PJSIP/voipfone-201-00000003
    -- Executing [s@bcab-bridge-conference:5] ConfBridge("PJSIP/6001-00000002", "1234") in new stack
    -- Channel CBAnn/1234-00000001;2 joined 'softmix' base-bridge <82d26f3b-14c6-4c57-a688-5476724f5c57>
    -- <PJSIP/6001-00000002> Playing 'conf-onlyperson.alaw' (language 'en_GB')
<--- Received SIP response (509 bytes) from UDP:46.31.X.X:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 139.59.X.X:5060;branch=z9hG4bKPja0f593d3-6a83-4fb6-800d-bbc2e54fbafe;received=139.59.X.X;rport=5060
From: <sip:30123456*201@sip.voipfone.net>;tag=e23b6c6b-da93-499b-9801-52955049a48c
To: <sip:0123456789@sip.voipfone.net>;tag=VF38b373b19e51e7a867614baf2245
Call-ID: 05bb5474-41e1-4164-9a9b-a1fac23ce847
CSeq: 14724 BYE
User-Agent: Voipfone Sip Network
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Contact: <sip:0123456789@46.31.X.X>
Content-Length: 0


    -- <PJSIP/6001-00000002> Playing 'confbridge-join.alaw' (language 'en_GB')
    -- <CBAnn/1234-00000001;1> Playing 'confbridge-join.gsm' (language 'en')
    -- Channel PJSIP/6001-00000002 joined 'softmix' base-bridge <82d26f3b-14c6-4c57-a688-5476724f5c57>

According to https://support.sonus.net/display/uxapidoc/q.850+cause+codes+-+reference, Q850.16 is “normal call clearing”.

When I hang “my end” of the call (ie: the initiating call, not the outgoing call which was triggered), this is all that happens on the console.

    -- Channel PJSIP/6001-0000003d left 'softmix' base-bridge <a8ffe6d4-1b3d-4fb4-aa3a-cd691a0d9063>
    -- <CBAnn/1234-00000006;1> Playing 'confbridge-leave.gsm' (language 'en')
    -- Channel CBAnn/1234-00000006;2 left 'softmix' base-bridge <a8ffe6d4-1b3d-4fb4-aa3a-cd691a0d9063>

So a few questions here: what is causing the call to clear down as soon as the confbridge kicks in (whether L is set or not in DIAL)
Why is it not obeying LIMIT? In the console doc for core show application dial (but missing from the online docs) it says, for option U:

NOTE: You cannot use any additional action post answer options in
conjunction with this option. Also, pbx services are run on the peer
(called) channel, so you will not be able to set timeouts via the
‘TIMEOUT()’ function in this routine.

If I understand this correctly, that makes U (and G) no use for this? In which case, what should I use to implement this?

I don’t understand what “pbx services are run on the peer (called) channel” means, but while I understand “you will not be able to set timeouts via the ‘TIMEOUT()’ function”, that doesn’t explain why “LIMIT” isn’t working.

Really appreciate any help here.


#8

It means that any dialplan in the macro or subroutine will be run as though the destination of the Dial application was the incoming caller. The actual incoming caller will sit there doing nothing.


#9

OK - I think that’s going to be OK as I don’t need it to do anything other than join the confbridge, and respond to a hangup when requested. Although, perhaps that’s why it’s not obeying the L(limit) command.

But that’s the least of the problems - getting a channel which has joined a confbridge to not hang up would be a good start.