SOLVED Action Based on Bridge Return Value - Possible?

Status
Not open for further replies.

JamesBorne

Active Member
Jan 24, 2019
294
57
28
Australia
My upstream sends a "Account in Use 156" when the sessions are maxed out.

I would simply like to inform the user instead of the rewrite to NORMAL_CLEARING (480) which causes the user to false panic.
I have modified an existing outbound route with an extra group to handle the action as follows:
1577681550531.png

At log point 1, the Freeswitch log successfully writes "Hello .... Account in Use 156"
But on the condition point 2, there is no value attached to the variable resulting in a FAIL on match:
1577681623252.png

I have tried setting the second condition to have an Inline of True, and I have tried exporting a new variable in group 1 and checking that. The exported variable also has no value on condition check.

Could someone suggest how I could use these variables in post-call check to see if the call failed due to max sessions?

Thanks all!
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
Hi James,
I replicated what you are trying to do and get the same result. I think the reason is that all the conditions in a dial plan statement get evaluated before any actions are processed. So when ${sip_invite_failure_phrase} is evaluated, it has not yet been set by the result of the bridge process. So it never matches so you always see the anti-action. That's my understanding, I probably have not explained it very well.

I think you can do what you want using LUA, I modified an example shown here:
https://freeswitch.org/confluence/display/FREESWITCH/Cause+Code+Substitution+Example

I modified my channel allowance on the SIP trunk to zero, so if I try to make a call the SIP proxy responds to me with "Request Terminated: Channel limit exceeded".

So the relevant bit of my my outbound route looks like this:
Screenshot from 2020-01-01 15-58-35.png

And this is the lua code:
Code:
-- channel_limit.lua
-- check for response text and apply hangup cause
--
uuid = argv[1];
api = freeswitch.API();
sip_invite_failure_phrase = api:executeString("uuid_getvar "..uuid.." sip_invite_failure_phrase");
if sip_invite_failure_phrase == "Request Terminated: Channel limit exceeded" then
    if ( session:ready() ) then
    session:execute("playback", "/usr/share/freeswitch/sounds/en/gb/rachael/ivr/8000/ivr-no_route_destination.wav")
    session:hangup("NORMAL_CIRCUIT_CONGESTION");
    end
end

Maybe this is a step in the right direction for you. Happy New Year!
 

JamesBorne

Active Member
Jan 24, 2019
294
57
28
Australia
Hey Adrian,

Mate you were spot on. Thank you so much for sourcing a solution and testing it for applicability!
Your explanation on condition variable parsing made a lot of sense. I also think you're right based on past experience.

If anyone else tests this, just be sure to change the hardcoded path to the sound file to a valid path, and to check variables with:
Code:
local log = require "resources.functions.log".call_flow_monitor
log.notice("channel_limit: " ..  sip_invite_failure_phrase )

Happy new year to you too!
 
Status
Not open for further replies.