Hello. I have a software developer creating a .Net / mono program to use as an AGI script. We are having problems getting it to stream files. From what we can tell, it is talking to asterisk correctly when called from the dial plan. Its stderr output goes to the asterisk console. But asterisk doesn't give any indication that it receives the STREAM FILE command. Asterisk simply quickly executes the program and moves to the next step of the dial plan, as though it didn't receive any commands from the program. We know it is running, and outputting its results, because we have called it from within a bash script, and in doing so, I set the script to output stdout to a txt file for testing (like this > /var/log/asterisk/querylog). When we do this, the file does end up with the first line showing STREAM FILE filename. We're at a bit of a loss as to what's going on. We have checked filenames and are pretty sure that there are no typos and that the files are there. Further, I have a perl agi script using asterisk::agi that also does a STREAM FILE which runs without any problem. In our dial plan, my perl script runs, gets data from the user via the keypad, puts it in a channel variable, then exits, and his AGI script is immediately called as the next step of the dial plan receiving the channel variable as an argument. It seems that there are not as many out there using mono / .net with AGI. The few examples we've found online are a bit dated. Any help would be greatly appreciated. Thanks much! - Doug Mortensen Network Consultant Impala Networks Inc CCNA, MCP, Security+ Linux+, Network+, A+ . www.impalanetworks.com P: (505) 327-7300 F: (505) 327-7545
Eric Wieling, Asteria Solutions Group
2009-Feb-25 23:41 UTC
[asterisk-users] AGI problem using mono (.Net)
Douglas Mortensen wrote:> > I have a software developer creating a .Net / mono program to use as an > AGI script. We are having problems getting it to stream files. From what > we can tell, it is talking to asterisk correctly when called from the > dial plan. Its stderr output goes to the asterisk console. But asterisk > doesn't give any indication that it receives the STREAM FILE command. > Asterisk simply quickly executes the program and moves to the next step > of the dial plan, as though it didn't receive any commands from the > program. > > We know it is running, and outputting its results, because we have > called it from within a bash script, and in doing so, I set the script > to output stdout to a txt file for testing (like this > > /var/log/asterisk/querylog). When we do this, the file does end up with > the first line showing STREAM FILE filename. > > We're at a bit of a loss as to what's going on. We have checked > filenames and are pretty sure that there are no typos and that the files > are there. Further, I have a perl agi script using asterisk::agi that > also does a STREAM FILE which runs without any problem. In our dial > plan, my perl script runs, gets data from the user via the keypad, puts > it in a channel variable, then exits, and his AGI script is immediately > called as the next step of the dial plan receiving the channel variable > as an argument.STDERR only goes to the Asterisk console if you are running 1.4 or later and enable agi debug in the CLI. I seem to recall something about AGIs not working correctly (streamfile or DTMF read) if your AGI script does not process the input Asterisk sends it on STDIN when Asterisk starts the AGI. I don't know if it applies here, but it's worth looking at. -- Eric Wieling * Asteria Solutions Group * Huntsville, AL Call centers * IVRs * Enterprise PBXs * Conferencing applications 256-705-0277 * http://www.asteriasgi.com/ * sales at asteriasgi.com
On Wed, 25 Feb 2009, Douglas Mortensen wrote:> I have a software developer creating a .Net / mono program to use as an > AGI script. We are having problems getting it to stream files. From what > we can tell, it is talking to asterisk correctly when called from the > dial plan. Its stderr output goes to the asterisk console. But asterisk > doesn't give any indication that it receives the STREAM FILE command. > Asterisk simply quickly executes the program and moves to the next step > of the dial plan, as though it didn't receive any commands from the > program.Maybe you need a new developer? (Just kidding...) The "agi debug" command may shed some light on the problem. I'm not a big fan of AGIs outputting to STDERR. I like to "pepper" my AGIs with syslog() statements to show the program state and variables.> We know it is running, and outputting its results, because we have > called it from within a bash script, and in doing so, I set the script > to output stdout to a txt file for testing (like this > > /var/log/asterisk/querylog). When we do this, the file does end up with > the first line showing STREAM FILE filename.You can configure Asterisk to log a whole bunch of cruft to syslog with the following statement in logger.conf: syslog.local0 = debug,dtmf,error,event,info,notice,verbose,warning I'll apologize in advance if the text below underestimates your AGI skills. The AGI interface (is that redundant?) can be summarized as: 1) Asterisk sends a bunch of cruft (the AGI environment variables) to your program's STDIN. 2) Your program sends a request to Asterisk via STDOUT. 3) Asterisk sends a result to your program via STDIN. 4) Your program does something else. 5) go to step 2. It's very simple, but not very forgiving. Let's imagine a simple AGI that reads the ANI as a channel variable, parses out the area code and sets it as a channel variable named NPA. Thus, you can simulate the AGI environment with a shell script. For an example, imagine the following script named test-my-agi.sh: # the standard AGI environment variables echo "agi_accountcode: " echo "agi_callerid: 1234567890" echo "agi_calleridname: sedwards" echo "agi_callingani2: 0" echo "agi_callingpres: 0" echo "agi_callingtns: 0" echo "agi_callington: 0" echo "agi_channel: SIP/201-09456478" echo "agi_context: newline" echo "agi_dnid: *" echo "agi_enhanced: 0.0" echo "agi_extension: *" echo "agi_language: en" echo "agi_priority: 1" echo "agi_rdnis: unknown" echo "agi_request: block-ani" echo "agi_type: SIP" echo "agi_uniqueid: 1195070681.28" echo "" # result for AGI command GET VARIABLE ANI echo "200 result=1 (5551234567)" # result for AGI command SET VARIABLE NPA echo "200 result=1" # (end of test-my-agi.sh) You can test your agi by executing: ./test-my-agi.sh | my-agi Since your AGI requires specific interaction with Asterisk to play the file this method will not allow you to fully test it, but it may help identify where you are violating the protocol. This technique can even be used in an actual debugger like gdb so you can step through your code line by line. Thanks in advance, ------------------------------------------------------------------------ Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000
Suggest, Use .net to do an web services and use curl+agi scripts to integrate your solutions. Regards, Luis Morales On Wed, Feb 25, 2009 at 6:37 PM, Douglas Mortensen <doug at impalanetworks.com> wrote:> Hello. > > I have a software developer creating a .Net / mono program to use as an > AGI script. We are having problems getting it to stream files. From what > we can tell, it is talking to asterisk correctly when called from the > dial plan. Its stderr output goes to the asterisk console. But asterisk > doesn't give any indication that it receives the STREAM FILE command. > Asterisk simply quickly executes the program and moves to the next step > of the dial plan, as though it didn't receive any commands from the > program. > > We know it is running, and outputting its results, because we have > called it from within a bash script, and in doing so, I set the script > to output stdout to a txt file for testing (like this > > /var/log/asterisk/querylog). When we do this, the file does end up with > the first line showing STREAM FILE filename. > > We're at a bit of a loss as to what's going on. We have checked > filenames and are pretty sure that there are no typos and that the files > are there. Further, I have a perl agi script using asterisk::agi that > also does a STREAM FILE which runs without any problem. In our dial > plan, my perl script runs, gets data from the user via the keypad, puts > it in a channel variable, then exits, and his AGI script is immediately > called as the next step of the dial plan receiving the channel variable > as an argument. > > It seems that there are not as many out there using mono / .net with > AGI. The few examples we've found online are a bit dated. Any help would > be greatly appreciated. > > Thanks much! > - > Doug Mortensen > Network Consultant > Impala Networks Inc > CCNA, MCP, Security+ > Linux+, Network+, A+ > . > www.impalanetworks.com > P: (505) 327-7300 > F: (505) 327-7545 > > > _______________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > ? http://lists.digium.com/mailman/listinfo/asterisk-users >-- --------------------------------------------------------------------------------- Luis Morales Consultor de Tecnologia Cel: +(58)416-4242091 --------------------------------------------------------------------------------- "Empieza por hacer lo necesario, luego lo que es posible... y de pronto estar?s haciendo lo imposible" Leonardo Da'Vinci ---------------------------------------------------------------------------------
Steve: ========================Thanks for the info on the agi debug command. We'll see what information we can garner with that. Thanks also for the advanced logging info. Unfortunately, we are pretty aware of how AGI works (at least at the level that you explained it). Thanks for the illustrations though. Also thanks for the info regarding the 1 active request at a time. We appreciate the information. Luis: ========================I'm not sure that we can use curl in our situation. We are querying an Microsoft SQL 2005 database server directly from the asterisk box. It doesn't look like curl support SQL. Let me know if I am not understanding your suggestion. - Doug Mortensen Network Consultant Impala Networks Inc CCNA, MCP, Security+ Linux+, Network+, A+ . www.impalanetworks.com P: (505) 327-7300 F: (505) 327-7545
An update here. Yesterday's problem has been solved (partly). After looking closer at the results of my perl script, as well as looking at the documentation, I realized that we were leaving the escape character argument off of the STREAM FILE command in the mono application. After appending "" to the STREAM FILE filename, we are now seeing asterisk "attempt" to play the file (both in the console and /var/log/asterisk/full log). New problem: =============Although we see the following in our logs / asterisk console: [Feb 26 11:11:05] VERBOSE[9824] logger.c: -- Playing 'filename' (escape_digits=) (sample_offset 0) All that the caller hears is a very brief click. And then the dial plan continues. This is causing me to wonder whether asterisk halts playback of the file, if the AGI script that send the STREAM FILE command completes/returns. Talking to my developer, I asked him to create a loop after sending the STREAM FILE command and read from stdin until he gets a string that starts with 200. I'm supposing that asterisk would send this AFTER the audio file has successfully played out. But again, this is only a guess. Thanks so much for the responses you provided yesterday. I look forward to further information you can assist us with. Sincerely, - Doug Mortensen Network Consultant Impala Networks Inc CCNA, MCP, Security+ Linux+, Network+, A+ . www.impalanetworks.com P: (505) 327-7300 F: (505) 327-7545