[Freeswitch-users] B-leg ringing after A-leg hangs-up. LUA.

Тимур Ситдиков sitdikovt at gmail.com
Tue Mar 2 04:50:25 UTC 2021


Ok, got it :-)
I'm new to lua, got this script based on the FS 1.8 book example script.
Bleg session is in Aleg thread entirely in that example.

Anyway, I've separated sessions and it works. Thank you a lot, Brian!

Regards, Tim

пн, 1 мар. 2021 г. в 22:04, Brian West <brian at freeswitch.com>:

> That's because the second legs Lua is running in the first legs session
> thread.  So it can't hang up yet.
>
> On Fri, Feb 26, 2021 at 3:40 PM Тимур Ситдиков <sitdikovt at gmail.com>
> wrote:
>
>> Hi Brian!
>> Yes, B hangs up right after pick up. Also there's an error about non
>> available channels in console.
>>
>>
>>
>> сб, 27 февр. 2021 г., 02:07 Brian West <brian at freeswitch.com>:
>>
>>> Tim,
>>>
>>> Based on your description, I would guess that the B-Leg hangs up when
>>> they answer after the a-leg is gone??
>>>
>>> /b
>>>
>>>
>>>
>>>
>>> On Fri, Feb 26, 2021 at 12:42 PM Тимур Ситдиков <sitdikovt at gmail.com>
>>> wrote:
>>>
>>>> Hi all. Need help with a simple call script.
>>>> I'm got this in dialplan
>>>> <extension name="call_lua_home">
>>>>       <condition field="destination_number" expression="^(1007)$">
>>>>         <!-- <action application="set" data="session_in_hangup_hook=true"/> -->
>>>> For hangup hook try
>>>>         <action application="lua" data="fork.lua"/>
>>>>       </condition>
>>>> </extension>
>>>> And this in fork.lua
>>>> if session:ready() then
>>>> api = freeswitch.API()
>>>> contact = api:execute("sofia_contact", "*/1007 at compA.com");
>>>> caller = session:getVariable("caller_id_number");
>>>> session1 = freeswitch.Session("{origination_caller_id_name="..caller..
>>>> "}[leg_timeout=30]"..contact.."");
>>>> -- session:setHangupHook("HangupHook");
>>>> if session1:ready() then
>>>>     freeswitch.bridge(session, session1);
>>>> end
>>>> freeswitch.consoleLog("WARNING","=====SCRIPT END\n");
>>>> session:hangup()
>>>> end
>>>>
>>>> When Caller is hanging up before B-leg answers - Bleg is continuing to
>>>> ring. There are still 2 channels in 'show channels' after A-leg hangs up.
>>>> I want to drop B-leg when A-leg hangs up. Is it possible?
>>>>
>>>> UPD Tried to use hangup hook. It works with stramFile, but no luck with
>>>> session.
>>>> function HangupHook(s, status)
>>>>     freeswitch.consoleLog("WARNING","Event fired breaking out\n");
>>>>     return exit;
>>>>     -- return die;
>>>> end
>>>>
>>>> session:answer();
>>>> session:setHangupHook("HangupHook");
>>>> while (session:ready() == true) do
>>>>
>>>>     session:streamFile(
>>>> "/usr/share/freeswitch/sounds/en/us/callie/ivr/16000/ivr-on_hold_indefinitely.wav"
>>>> );
>>>>
>>>> -- session1 = freeswitch.Session("{origination_caller_id_name="..caller.."}[leg_timeout=30]"..contact.."");
>>>> end
>>>> freeswitch.consoleLog("WARNING","=====SCRIPT END\n");
>>>> session:hangup()
>>>> end
>>>>
>>>> Can anyone help me with this?
>>>>
>>>> Thanks! Regards,Tim
>>>>
>>>> _________________________________________________________________________
>>>>
>>>> The FreeSWITCH project is sponsored by SignalWire
>>>> https://signalwire.com
>>>> Enhance your FreeSWITCH install with disruptive priced SMS and PSTN
>>>> services.
>>>> Build your next product on our scalable cloud platform.
>>>>
>>>> Join our online community to chat in real time
>>>> https://signalwire.community
>>>>
>>>> Professional FreeSWITCH Services
>>>> sales at freeswitch.com
>>>> https://freeswitch.com
>>>>
>>>> Official FreeSWITCH Sites
>>>> https://freeswitch.com/oss
>>>> https://freeswitch.org/confluence
>>>> https://cluecon.com
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org
>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>> UNSUBSCRIBE:
>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>> https://freeswitch.com
>>>
>>>
>>>
>>> --
>>>
>>> Brian West | Co-founder and Developer
>>>
>>> Need Commercial support? email sales at freeswitch.com
>>>
>>> FreeSWITCH Solutions | 17345 Civic Drive #2531 Brookfield, WI 53045
>>> <https://maps.google.com/?q=17345+Civic+Drive+%232531+Brookfield,+WI+53045&entry=gmail&source=g>
>>>
>>> Email: brian at freeswitch.com
>>>
>>> Mobile: 918-424-9378
>>>
>>> Website: https://www.FreeSWITCH.com <https://www.freeswitch.com/>
>>>
>>> [image: https://www.facebook.com/signalwireinc?src=email]
>>> <https://www.facebook.com/freeswitch> [image:
>>> https://twitter.com/freeswitch] <https://twitter.com/freeswitch>
>>> _________________________________________________________________________
>>>
>>> The FreeSWITCH project is sponsored by SignalWire https://signalwire.com
>>> Enhance your FreeSWITCH install with disruptive priced SMS and PSTN
>>> services.
>>> Build your next product on our scalable cloud platform.
>>>
>>> Join our online community to chat in real time
>>> https://signalwire.community
>>>
>>> Professional FreeSWITCH Services
>>> sales at freeswitch.com
>>> https://freeswitch.com
>>>
>>> Official FreeSWITCH Sites
>>> https://freeswitch.com/oss
>>> https://freeswitch.org/confluence
>>> https://cluecon.com
>>>
>>> FreeSWITCH-users mailing list
>>> FreeSWITCH-users at lists.freeswitch.org
>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>> https://freeswitch.com
>>
>> _________________________________________________________________________
>>
>> The FreeSWITCH project is sponsored by SignalWire https://signalwire.com
>> Enhance your FreeSWITCH install with disruptive priced SMS and PSTN
>> services.
>> Build your next product on our scalable cloud platform.
>>
>> Join our online community to chat in real time
>> https://signalwire.community
>>
>> Professional FreeSWITCH Services
>> sales at freeswitch.com
>> https://freeswitch.com
>>
>> Official FreeSWITCH Sites
>> https://freeswitch.com/oss
>> https://freeswitch.org/confluence
>> https://cluecon.com
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> https://freeswitch.com
>
>
>
> --
>
> Brian West | Co-founder and Developer
>
> Need Commercial support? email sales at freeswitch.com
>
> FreeSWITCH Solutions | 17345 Civic Drive #2531 Brookfield, WI 53045
> <https://maps.google.com/?q=17345+Civic+Drive+%232531+Brookfield,+WI+53045&entry=gmail&source=g>
>
> Email: brian at freeswitch.com
>
> Mobile: 918-424-9378
>
> Website: https://www.FreeSWITCH.com <https://www.freeswitch.com/>
>
> [image: https://www.facebook.com/signalwireinc?src=email]
> <https://www.facebook.com/freeswitch> [image:
> https://twitter.com/freeswitch] <https://twitter.com/freeswitch>
> _________________________________________________________________________
>
> The FreeSWITCH project is sponsored by SignalWire https://signalwire.com
> Enhance your FreeSWITCH install with disruptive priced SMS and PSTN
> services.
> Build your next product on our scalable cloud platform.
>
> Join our online community to chat in real time
> https://signalwire.community
>
> Professional FreeSWITCH Services
> sales at freeswitch.com
> https://freeswitch.com
>
> Official FreeSWITCH Sites
> https://freeswitch.com/oss
> https://freeswitch.org/confluence
> https://cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> https://freeswitch.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20210302/b8d51854/attachment-0001.html>


More information about the FreeSWITCH-users mailing list