Bridge answered parked leg and ringing leg

Hello all,

I’m receiving an a-leg that’s in a ringing state.
Then I’m receiving another leg (b-leg) which i’m answering and parking.
This b-leg at some point sends a reINVITE, that triggers a lua (via execute_on_sip_reinvite) which tried to bridge the 2 legs.
Event though it seems to work, both legs are hung up immediately, both with ORIGINATOR_CANCEL.

I’ve tried:

  • Answering A-Leg

  • Execute on B-Leg an intercept to A-leg

  • NOT Answering A-Leg

  • Execute on B-Leg an intercept to A-leg

  • Answering A-Leg

  • Execute on A-Leg an intercept to B-leg (with -bleg)

  • NOT Answering A-Leg

  • Execute on A-Leg an intercept to B-leg (with -bleg)

  • Answering A-Leg

  • Execute on B-Leg: uud_bridge B-Leg A-Leg

-NOT Answering A-Leg

  • Execute on A-Leg: uud_bridge B-Leg A-Leg

nothing seems to work…

Any ideas?

Thanks!

answer a leg and park, then from bleg intercept aleg.

Hello @dujinfang

Many thanks for the reply, but that’s not working.
The legs seem to be bridged but fs hangs up immediately.
The dialplan executed on the reINVITE (which is when i want to bridge the leg to the A-Leg):

<action application="set" data="hangup_after_bridge=false"/>
<action application="set" data="api_res_answer=${uuid_answer ${a_leg}}"/>
<action application="set" data="api_res_park=${uuid_park ${a_leg}}"/>
<action application="intercept" data="${a_leg}"/>

console output:

[DEBUG] switch_ivr_bridge.c:2213 (sofia/intercept/13153860607@dev.tncp.textnow.com) State Change CS_EXECUTE -> CS_HIBERNATE
[DEBUG] switch_ivr_bridge.c:2215 (sofia/legacy/16313643986@dev.tncp.textnow.com) State Change CS_PARK -> CS_HIBERNATE
[NOTICE] switch_ivr_bridge.c:2335 Hangup sofia/legacy/17053007553@dev.tncp.textnow.com [CS_CONSUME_MEDIA] [PICKED_OFF]

First leg is hung up with “ORIGINATOR_CANCEL” and the second leg with NORMAL_CLEARING…

Any help is appreciated!

David

Can you also show the dialplan of the a-leg, if it did answer, it should not show as originator cancel.

Also a full log with SIP (sofia global siptrace on) is helpful.

Hello and thansk!

Aleg Dialplan:

<extension name="fsDialer_get_all_calls_with_vm">
  <condition field="destination_number" expression="(.*)">
    <action application="set" data="fromProvider=${sip_h_X-Provider}"/>
    <action application="set" data="fsPath=${distributor sip-dialog ${sofia profile internal gwlist down}}"/>
    <action application="export" data="limitKey=${sip_h_X-From-URI}"/>
    <action application="unset" data="sip_h_X-Provider"/>
    <action application="unset" data="sip_h_P-RTP-Proxy"/>
    <action application="unset" data="sip_h_X-From-URI"/>
    <action application="set" data="accountcode=fsDialer"/>
    <action application="ring_ready"/>
    <action application="lua" data="/usr/share/freeswitch/scripts/onInboundCall.lua"/>
    <action application="set" data="hangup_after_bridge=false"/>
    <action application="set" data="continue_on_fail=true"/>
    <action application="set" data="jitterbuffer_msec=20:160:20"/>
    <action application="set" data="rtp_jitter_buffer_during_bridge=true"/>
    <action application="sched_broadcast" data="+${fsd_pstn_answer_timeout} hangup::NO_USER_RESPONSE both"/>
    <action application="set" data="api_task=${uuid_getvar ${uuid} last_sched_id}"/>
    <action application="set" data="bridge_generate_comfort_noise=true"/>
    <action application="set" data="_nolocal_bridge_generate_comfort_noise=true"/>
    <action application="bridge" data="${obString}"/>
    <action application="lua" data="/usr/share/freeswitch/scripts/onBridgeFail.lua" />
    <action application="sched_cancel" data="${api_task}"/>
    <action application="lua" data="/usr/share/freeswitch/scripts/onVoicemail.lua"/>
  </condition>

Bleg dialplan:

    <extension name="intercept">
        <condition field="destination_number" expression="^intercept_([0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12})$">
            <actoin application="log" data="ERR Parking call with intercept uuid: $1 b_leg_uuid=${uuid}"/>
            <action application="set" data="dump_result=${uuid_dump $1 b_leg_uuid ${uuid}}"/>
            <action application="set" data="var_set_result=${uuid_setvar $1 b_leg_uuid ${uuid}}"/>
            <action application="set" data="hangup_after_bridge=true"/>
            <actoin application="log" data="ERR a_leg variable set: ${var_set_result}"/>
            <action application="set" data="res=${uuid_setvar ${uuid} execute_on_sip_reinvite 'lua /usr/share/freeswitch/scripts/InterceptEventsSession.lua'}"/>
            <action application="answer"/>
            <action application="park"/>
        </condition>
    </extension>

The lua script triggered on reINVITE is simply:

init()
my_leg_uuid = session:getVariable(“uuid”)
a_leg_uuid = api:executeString(“uuid_getvar " … my_leg_uuid … " destination_number”):gsub(“^intercept_”,“”)
session:setVariable(“a_leg”,a_leg_uuid)
session:execute(“transfer”,“answer_” … a_leg_uuid);

and the transferred to extension is:

    <extension name="intercept_answer">
        <condition field="destination_number" expression="^answer_([0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12})$">
            <action application="set" data="api_res_setvar=${uuid_broadcast ${a_leg} hangup_after_bridge true}"/>
            <actoin application="log" data="ERR api_res: ${api_res}"/>

            <action application="set" data="hangup_after_bridge=false"/>

            <action application="set" data="api_res_answer=${uuid_answer ${a_leg}}"/>
            <action application="log" data="ERR api_res_answer=${api_res_answer}"/>

            <action application="set" data="api_res_park=${uuid_park ${a_leg}}"/>
            <action application="log" data="ERR api_res_park=${api_res_park}"/>

            <action application="intercept" data="-bleg ${a_leg}"/>
        </condition>
    </extension>

There’s a limit of 2000 chars

So, because the first leg (call it A-leg) was being bridged with another leg and ringing, what end up working was:

  • Transfer the A-leg to an extension than answered it + park it
  • Then intercept from B-leg to A-leg

Thanks for the help!

David