[Freeswitch-users] CoreSession::hangup after MOVED on IVR calls

Piccinin Francesco francesco.piccinin at insiel.it
Wed Mar 29 19:22:17 MSD 2017


Hi Brian,
many thanks for your feedback!

Find below some extract from our FS dialplan.
Our SIP system is composed by an Opensips front-end that balances calls on Freeswitch hosts. Realtime data and static config are backended on mysql db.


default.xml: a lua script profiling caller / called setting channel_variables.

services.xml:
<include>
  <condition field="${service_type}" expression="IVR" break="on-true">
        <action application="set" data="default_language=it"/>
        <action application="set" data="hangup_after_bridge=false"/>
        <action application="set" data="force_transfer_context=ivrs"/>
        <action application="lua" data="services/ivr.lua ${did}" inline="true"/>
        <action application="answer"/>
        <action application="ivr" data="${ivr_name}"/>
        <action application="transfer" data="${fallback}"/>
  </condition>
</include>

calls.xml:
<include>
  <condition field="${service_type}" expression="^NONE$"  break="on-true">
      <action application="info"/>
      <action application="lua" data="functions/consult_xfer_limit_int.lua ${ext} ${cCalled} ${domain_name} ${maxcalls} ${busytriggerA} ${shd_line} ${maxcallsB} ${busytriggerB}"/>
      <action application="set" data="effective_caller_id_number=${ext}"/>
      <action application="set" data="effective_caller_id_name=${my_dname}"/>
      <action application="set" data="hold_music=${moh_path}" inline="true"/>
      <action application="set" data="transfer_ringback=${moh_path}"/>
      <action application="export" data="pbx=${pbx}"/>
      <action application="export" data="domain_name=${domain_name}"/>
      <action application="export" data="maxcalls=${maxcalls}"/>
      <action application="limit" data="db ${domain_name} BSY_${cCalled} ${busytriggerB} !USER_BUSY"/>
      <action application="limit" data="db ${domain_name} MAX_${ext} ${maxcalls} !USER_BUSY"/>
      <action application="limit" data="db ${domain_name} BSY_${ext} ${busytriggerA} !USER_BUSY"/>-->
      <action application="bind_meta_app" data="1 ab s execute_extension::dx XML features"/>
      <action application="bind_meta_app" data="2 ab s execute_extension::att_xfer XML features"/>
      <action application="bind_meta_app" data="3 ab s execute_extension::parking XML features"/>
      <action application="set" data="hangup_after_bridge=true"/>
      <action application="set" data="continue_on_fail=true"/>
      <action application="export" data="alert_info=http://127.0.0.1/ring.wav;info=${alert_info};x-line-id=0"/>
      <action application="set" data="bypass_media=${lan}"/>
      <action application="set" data="t38_passthru=true"/>
      <action application="export" data="t38_passthru=true"/>
      <action application="set" data="disable_q850_reason=true"/>
      <action application="set" data="sip_redirect_context=redir"/>
      <action application="export" data="sip_redirect_context=redir"/>
      <action application="export" data="nolocal:execute_on_answer=lua functions/clean_pickup.lua ${uuid}"/>
      <action application="set" data="callee_id_name=${cid_name}"/>
      <action application="export" data="callee_id_name=${cid_name}"/>
      <action application="set_profile_var" data="callee_id_name=${cid_name}"/>
      <action application="set" data="leg=A"/>
      <action application="export" data="nolocal:leg=B"/>
      <action application="bridge" data="{sip_invite_domain=${domain_name},sip_cid_type=pid,presence_id=${cCalled}@${domain_name}}${sofia_contact(${cCalled}@${domain_name})}"/>
      <action application="set" data="continue_on_fail=USER_BUSY,ORIGINATOR_CANCEL"/>
      <action application="hangup" data="USER_BUSY"/>
  </condition>
</include>

  
redir.xml:
<include>
  <context name="redir">
    <!-- On Moved , manage redirection -->
    <extension name="redirections">
      <condition field="destination_number" expression="^(\d+)$">
            <action application="log" data="INFO REDIRECTED"/>
            <action application="info"/>
            <action application="set" data="ignore_early_media=true"/>
            <action application="set" data="hangup_after_bridge=false"/>
            <action application="set" data="continue_on_fail=true"/>
            <action application="set" data="bypass_media=false"/>
            <!--<action application="answer"/>-->
            <action application="set" data="leg=A"/>
            <action application="export" data="nolocal:leg=B"/>
            <action application="lua" data="functions/call_redirect.lua  ${cCalled} ${destination_number}"/>
      </condition>
    </extension>
  </context>
</include>


call_redirect.lua profile cCalled (forwarder ext) and destination_number (forward destination) check session status with session:ready() and execute a bridge with:

app="{ignore_early_media=true,hangup_after_bridge=true,origination_caller_id_name='Da:"..caller.."',originate_timeout=25}sofia/gateway/"..gw[i].."/"..redirected;
session:execute("bridge", app);

Please note that a-leg is terminated just after b-leg is terminated with originator_cancel (sip 487) on SIP moved received from forwarded extensions.

Thanks in advance for you help

Francesco



Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list