[Freeswitch-users] Reroute a Call Based on the Disconnect Cause

Delian Tashev delianspam at gmail.com
Mon Oct 26 08:35:30 PDT 2009


Hello VoIP Geeks!

I am looking for a way to reroute calls on specific disconnect reasons. My
application is in Python. I will provide my solves so far, which for some
reason I cannot use. Why I need rerouting? Well, I am using the LCR module
which provides multiple routes per destination, like this:
routes=
[lcr_carrier=fs-rocks.com,lcr_rate=0.15000]sofia/default/1174 at 194.135.34.200
:5062|
[lcr_carrier=fs-rocks.com,lcr_rate=0.16000]sofia/default/1174 at 194.135.34.200
:5064

Solve 1: Python solve
Split the routes string to multiple routes. Bridge the call. Check if the
call failed and bridge again.

ivr_reroute_on=(\

    "CALL_REJECTED",\
    "CRASH",\
    "INVALID_NUMBER_FORMAT",\
    "NORMAL_TEMPORARY_FAILURE",\
    "NO_ROUTE_DESTINATION",\
    "NO_USER_RESPONSE",\

    "NUMBER_CHANGED",\

    "RECOVERY_ON_TIMER_EXPIRE",\

    "SERVICE_NOT_IMPLEMENTED",\

)       
...
session.execute("bridge", route)
hangup_cause = str(session.getVariable("originate_disposition"))
if hangup_cause in ivr_reroute_on:
 #bridge again
 ...
else:
 ...
 #do not bridge again

This is tested and works. However my manager does not likes it. I am not
commenting on the side effects of this code (i.e. if you have some
timers/schedules/scheduled events etc).

Solve 2: Freeswitch Source Code solve
Modify the source code of "switch_ivr_originate.c":

                                                if (to &&
!oglobals.continue_on_timeout) {
                                                                goto
outer_for;
                                                }
                                                after line 2523:

                                                +if
(switch_channel_cause2str(*cause) == SWITCH_CAUSE_CALL_REJECTED ) {
                                                +             goto
outer_for;
                                                +}

(In the best case I will add a new channel variable to Freeswitch to control
all the disconnect reasons from here) However my manager again does not
likes this. He says that I am not good enough in C/C++ to use this solution.

Solve 3: continue_on_fail
I have tried using the channel variable "continue_on_fail" which I believe
works only in the dialplan with no luck. I was unable to get it running both
in the dialplan and in Python. By the way I saw that "continue_on_fail" is
indeed implemented elsewhere, while "continue_on_timeout" is exactly in
"switch_ivr_originate.c" as expected.

Solve 4:
So can you please people recommend me any other solution? Any function or
variable to do the trick?

Thank you for your time and help!

Delian Tashev





More information about the FreeSWITCH-users mailing list