Bug or broken? AGI stream_file escape_digits not working

Hi all thanks for taking the time to look at this.

When using control_stream_file, stream_file, or get_options the “escape_digits” only works the first time. if using ‘#’ if using a number 0-9 it works fine each time. I’m not sure if this is a bug or if I need to do some kind of “reset” between calls??

My Python Code:

from asterisk.agi import *

escape_all = ['1','2','3','4','5','6','7','8','9','0','#','*']

agi = AGI()

digit = agi.stream_file('custom/please-enter', escape_all)
agi.verbose("Caught:" + str(digit))

tmp =  agi.stream_file('custom/start-dictation', escape_all)
agi.verbose("Caught:" + str(tmp))

agi.hangup()

In this test the caller can press any of the escape digits and it is caught and printed to the log but only the first time. The second one, does not work… it doesn’t matter what digit the user presses, it plays the soundfile to completion and exits with nothing caught … the logs display nothing being caught for the second attempt.
Log output

 /home/asterisk/Dictator/run.sh: ----------------------- TEST ----------------------
<TRUNCATED>AGI Tx >> 200 result=1
<TRUNCATED>AGI Rx << STREAM FILE custom/please-enter "1234567890#*" 0
    -- <TRUNCATED> Playing 'custom/please-enter.slin' (escape_digits=1234567890#*) (sample_offset 0) (language 'en')
       > 0x3e69f30 -- Strict RTP switching to RTP target address <REDACTED> as source
<TRUNCATED>AGI Tx >> 200 result=35 endpos=20640
<TRUNCATED>AGI Rx << VERBOSE "caught: #" 1
 /home/asterisk/Dictator/run.sh: caught: #
<TRUNCATED>AGI Tx >> 200 result=1
<TRUNCATED>AGI Rx << STREAM FILE custom/start-dictation "1234567890#*" 0
    -- <TRUNCATED> Playing 'custom/start-dictation.slin' (escape_digits=1234567890#*) (sample_offset 0) (language 'en')
       > 0x3e69f30 -- Strict RTP learning complete - Locking on source address <REDACTED>
<TRUNCATED>AGI Tx >> 200 result=0 endpos=56080
<TRUNCATED>AGI Rx << VERBOSE "caught: " 1
 /home/asterisk/Dictator/run.sh: caught: 
<TRUNCATED>AGI Tx >> 200 result=1

I can sorta work around it but as this is for a dictation project I will need to request user input values several times.

Thank you in advance for any insight into this…

If the input is printed on the asterisk console, it means is received by Asterisk and passed to the AGI, but why the Python is not terminating the playing of the file I think is more related to your Python library

The Python Library is just a wrapper for the AGI calls provided directly by Asterisk. And recommended by Asterisk → Asterisk Gateway Interface (AGI) - Asterisk Project - Asterisk Project Wiki I’m using the pyst2 wrapper.

On the first pass if you use a # sign it works, but the second time it does not interrupt regardless of what you enter and it does not return a value. However if you do an actual digit say 6… then the next one will also interrupt on a 6 and return 6… to be clear the issue of it continuing to play is not the issue but rather that it does not return the keyed in value.

I do understand your issue, but in this case there is one of the 2 options, verify you re using an Asterisk LTS version because maybe this issue is only present on specifics Asterisk versions or trying getting some help directly with the library developer

ok to circle back then… the original question is if this is a bug or am I doing something wrong.

I assume at this point by your response it’s not something that I am doing wrong but either the library or the asterisks version… that being said I’ll look into upgrading. (it’s an older version)…