Search code examples
freeswitch

Intercepting a call disconnects all call legs


This is the scenario A call to FS which connects it to B. B dial an extension(bind_digit), That extension is checked in DB to fetch the Number Associated with Extension. Then FS calls That number(C). Now i want to Connect A to C. here is my sample code

ns = freeswitch.Session(dialStr..SIP_TRUNK..number)
while (ns:ready() and dispo ~= 'ANSWER' ) do
    dispo = ns:getVariable("endpoint_disposition")
    os.execute("sleep 1")
end

if (dispo == 'ANSWER') then
    ns:execute("intercept",auuid)
    freeswitch.consoleLog("INFO","Intercepted the call \n")
end 

but after Intercept all call gets hangup. What i am doing wrong..!


Solution

  • Oops.. i forgot to set ns:setAutoHangup(false). So session was getting destroy after executing last statement of script.