Re: [asterisk-users] AGI problem using mono (.Net)
Hi douglas, I made an AGI script with curl in my dial-plan. Take a look: [custom-login] exten = s,1,Set(LOGINOK=0) exten = s,2,Read(codigo|custom/codigo|4||3|3) exten = s,3,Read(clave|custom/clave|4||3|3) exten = s,4,Set(LOGINOK=${CURL(http://URL/cgi-bin/login.pl?codigo=${codigo}clave=${clave})}) exten = s,5,Set(TRY=$[${TRY} + 1]) exten = s,6,GotoIf($[${TRY} 2]?custom-finish,s,1:) exten = s,7,GotoIf($[${LOGINOK} = 0]?custom-login,s,4:) exten = s,8,GotoIf($[${LOGINOK} = 1]?custom-ok,s,1:) login.pl -- #!/usr/bin/perl use CGI qw/:standard/; use strict; my $codigo = (param('codigo') ne undef) ? param('codigo') : 0; my $clave = (param('clave') ne undef) ? param('clave') : 0; my $i = 0; $i = ($codigo eq $clave) ? 1 : 0; print Content-type: text/html\n\n; print $i; -- Now you can use asterisk+curl to send and receive data. If you are working with .net you can make web services integration + asterisk + curl Have an nice day, Regards, Luis Morales On Thu, Feb 26, 2009 at 2:07 PM, Douglas Mortensen d...@impalanetworks.com wrote: 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 ___ - Show quoted text - -- 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 - ___ -- 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
Re: [asterisk-users] AGI problem using mono (.Net)
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 ___ -- 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
Re: [asterisk-users] AGI problem using mono (.Net)
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 ___ -- 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
Re: [asterisk-users] AGI problem using mono (.Net)
On Thu, 26 Feb 2009, Douglas Mortensen wrote: 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. If your AGI is exiting before the sound file has finished and without reading the result from STDIN, you have violated the protocol. 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. All it takes is a single line oriented read. This is pretty elemental to the protocol -- issue a request, read the result. Most (all?) AGI libraries wrap these two steps into a single function call so the library user never has the opportunity to do anything in between. I'm supposing that asterisk would send this AFTER the audio file has successfully played out. But again, this is only a guess. It makes sense that Asterisk sends the result when the request is finished, successful or not. A few more suggestions: ) Try to STREAM FILE demo-congrats. ) Verify that your sound file is playable (in the correct format for the codecs you have loaded) by using playback() in the dialplan. Apologies if it is too basic (but still I forget sometimes...) that the file name is specified without the file type and is relative to Asterisk's sound directory (usually /var/lib/asterisk/sounds/) if the file name does not start with a slash. The error message you showed above looks like STREAM FILE is finding the file. I'm guessing that you are still violating the protocol or that the file is not in an acceptable format for the codecs you have loaded. It appears that you did not use an existing AGI library. Why not? Thanks in advance, Steve Edwards sedwa...@sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000 ___ -- 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
[asterisk-users] AGI problem using mono (.Net)
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
Re: [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/ * sa...@asteriasgi.com ___ -- 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
Re: [asterisk-users] AGI problem using mono (.Net)
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 sedwa...@sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000 ___ -- 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
Re: [asterisk-users] AGI problem using mono (.Net)
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 d...@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 - ___ -- 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
Re: [asterisk-users] AGI problem using mono (.Net)
On Wed, 25 Feb 2009, Steve Edwards wrote: 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. 1a) Your program must read all of the AGI environment variables. 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. If you output anything to STDOUT that is not expected, you're hosed. It is possible to write multi-threaded AGIs (eg, play a file while you are waiting for an answer from your credit card processor), but you can only have 1 request active (you've issued the request and you haven't received a result yet) at a time. Thanks in advance, Steve Edwards sedwa...@sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000 ___ -- 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