[Freeswitch-users] Hangup_hook is not getting called in mod_python script

Michael Jerris mike at jerris.com
Thu Sep 14 15:46:35 UTC 2017


> On Sep 14, 2017, at 6:01 AM, Deepika Yadav <deepikay at iiitd.ac.in> wrote:
> 
> Hi,
> 
> I have implemented a functionality where when a person with his mobile phone number calls a specific number (that of SIM inserted in our GOIP hardware), the incoming is hanged and that person is called back.
> 
> After the IVR menu starts playing and if in between caller hangs up, hangup_event is not detected and the registered hangup_hook does not get called.
> 
> Code is as follows;
> 
> XML file that starts python script when the person answers the call:
> 
> <extension name="record_topic">
>         <condition field="destination_number" expression="^4449"> 
>         <action application="set" data="execute_on_answer=python python.sangoshthi_IVR_handler"/>
> 
>          <action application="sleep" data="30000"/>
>         </condition>
> </extension>
> 

This part is really strange.  If you want to execute that python script when the call answers after originating to the endpoint, just make the python the only thing in dial plan, and use ignore_early_media on the originate.  It won’t hit the dial plan until answer.  As for the rest of your question, it seems like you are saying you don’t get the hanguphook when the python script isn’t running?

> Python Script handler:
> 
> def handler(session, args):
>    
>     session.setHangupHook(hangup_hook)
>     session.setInputCallback(input_callback)
> 
>     print('session object value is ', str(session))
> 
>     callerid =  session.getVariable('caller_id_number')
>     call_uuid = session.getVariable('uuid')
> 
>     phone_number = callerid[len(callerid)-10:]
> 
>      initial_greeting(session, phone_number, call_uuid)
> 
> 
> def hangup_hook(session, what, args=''):
>     """
>     Must be explicitly set up with session.setHangupHook(hangup_hook).
> 
>     `session` is a session object.
>     `what` is "hangup" or "transfer".
>     `args` is populated if you pass extra args to session.setInputCallback().
> 
>     """
>     print('PERSON HANGED UPPPPP...........')
>     freeswitch.consoleLog("INFO", "hangup hook for '%s'\n" % what)
> 
> -- 
> Regards,
> Deepika
> https://deepikay.wixsite.com/deepika <https://deepikay.wixsite.com/deepika>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.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
> http://www.freeswitch.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20170914/9d39de9d/attachment.html>


More information about the FreeSWITCH-users mailing list