Custom timeout value always reverts to a fix 10sec. timeout

Hey everyone,

I’m using some custom extensions in my freePBX. Currently, I stumbled across a problem that I can’t seem to fix…

First, this is my extension I’m referring to in the following post:

[test]
exten => s,1,Answer()
same => n,Set(timeout=3) ; Set default timeout value to 3 seconds (adjust as needed)
same => n,Set(digits=)
same => n,Set(start_time=${EPOCH}) ; Get the start time of the call
same => n,Set(digit_input=false) ; Set initial digit input flag to false
same => n,Set(timeout_expired=false) ; Set initial timeout flag to false
same => n(loop_start),Read(digit,,1)
same => n,GotoIf($["${digit}" = ""]?check_digit_input:save_digit_input)
same => n(save_digit_input),Set(digits=${digits}${digit})
same => n,Set(digit_input=true) ; Set digit input flag to true when at least one digit is entered
same => n,Set(start_time=${EPOCH}) ; Reset the start time on new DTMF input
same => n,Goto(check_timeout)
same => n(check_digit_input),GotoIf($[${digit_input} = false]?test,s,1:wait_for_input)
same => n(wait_for_input),Set(time_elapsed=$[${EPOCH}-${start_time}])
same => n,GotoIf($[${time_elapsed} < ${timeout}]?loop_start:process_input)
same => n(check_timeout),Set(time_elapsed=$[${EPOCH}-${start_time}])
same => n,GotoIf($[${time_elapsed} >= ${timeout}]?set_timeout_expired:loop_start)
same => n(set_timeout_expired),Set(timeout_expired=true)
same => n,Goto(process_input)
same => n(process_input),GotoIf($[${timeout_expired} = true]?timeout_exit)
same => n,System(/usr/bin/python3 /home/custom-scripts/xxxxx.py ${digits})
same => n,Playback(/home/custom-scripts/generated-audio/${digits})
same => n,System(/usr/bin/python3 /home/custom-scripts/xxxx2.py ${digits})
same => n(exit),Hangup()
same => n(timeout_exit),Playback(tt-weasels)
same => n,Hangup()

A short explanation:

My extension has a set timeout value that should be editable. It’s this one:

same => n,Set(timeout=10) ; Set default timeout value to 10 seconds (adjust as needed)

When no DTMF-input was detected within the timeout, the extension just starts again, waiting for DTMF input:

same => n(check_digit_input),GotoIf($[${digit_input} = false]?test,s,1:wait_for_input)

When at least one DTMF input was detected during the timeout, these are being called, which then perform some actions:

same => n,System(/usr/bin/python3 /home/custom-scripts/xxxxx.py ${digits})
same => n,Playback(/home/custom-scripts/generated-audio/${digits})
same => n,System(/usr/bin/python3 /home/custom-scripts/xxxx2.py ${digits})
same => n(exit),Hangup()

!IMPORTANT! With every DTMF input detected, the timeout starts again before calling these :point_up_2::


So theoretically when pressing x-digits with each a delay of 3 seconds it would allow infinite DTMF inputs, because the timeout always restarts.
When pressing for example 5-digits with a delay of 3 seconds and then waiting for the defined timeout, the script executes these:

same => n,System(/usr/bin/python3 /home/custom-scripts/xxxxx.py ${digits})
same => n,Playback(/home/custom-scripts/generated-audio/${digits})
same => n,System(/usr/bin/python3 /home/custom-scripts/xxxx2.py ${digits})
same => n(exit),Hangup()

So far, so good. The extension works on my server and does basically everything important…
However, when editing the timeout value, it completely ignores my changes…

It doesn’t matter if I put in (timeout=10) or (timeout=2)… It always uses exactly 10 meaning a 10 sec. timeout…

Does anyone know what’s wrong? I’ve been trying for hours to debug using stopwatches etc. but the timeout value basically doesn’t seem to affect anything… It’s always 10sec no matter what value I define…

Thanks a lot for your help!

Perhaps

TIMEOUT(absolute) (dialplan function) - NEW.

Are you reloading the configuration when you change the file? This is not automatic.

Thank you, but this didn’t help…

Yeah sure…

I ‘solved’ the issue by just ignoring the timeout…

In my case, it’s also fine if the DTMF get parsed to the script when ‘#’ has been pressed after the last input. This also simplifies everything a lot…

This work fine now:

[test]
exten => s,1,Answer()
same => n,Set(digits=)
same => n,Read(digits,,100) ;reads up to 100 dtmf inputs an parses them to the script when '#' was pressed as last digit.
same => n,System(/usr/bin/python3 /home/custom-scripts/xxxxx.py ${digits})
same => n,Playback(/home/custom-scripts/generated-audio/${digits})
same => n,System(/usr/bin/python3 /home/custom-scripts/xxxxxx.py ${digits})
same => n,Hangup()

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.