I am trying to run a shell script using asterisk AGI. I have used the tutorial mentioned here
http://www.shiffman.net/p5/asterisk/
My extensions.conf is as follows
[default]
include => clicall
[clicall]
exten => _X,1,Goto(s,1);
exten => _X.,1,Goto(s,1);
exten => s,1,Answer();
exten => s,n,EAGI(runEAGI.sh);
The script I am trying to run (runEAGI.sh) is as follows
#!/bin/bash
java /home/sphata001/Downloads/EAGI/JEAGIClient $$
The permissions have been set as 755 and the script is placed in /var/lib/asterisk/agi-bin/. The java file(JEAGIClient) has been compiled beforehand as well . When executing the script manually it runs fine and connects to the server.
But when making a call from SIP client the script executes according to asterisk console but no results are to seen.
I get the following output in the console
== Using SIP RTP CoS mark 5
-- Executing [888#default:1] Goto("SIP/1001-00000027", "s,1") in new stack
-- Goto (default,s,1)
-- Executing [s#default:1] Answer("SIP/1001-00000027", "") in new stack
-- Executing [s#default:2] EAGI("SIP/1001-00000027", "runEAGI.sh") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/runEAGI.sh
-- <SIP/1001-00000027>AGI Script runEAGI.sh completed, returning 0
-- Auto fallthrough, channel 'SIP/1001-00000027' status is 'UNKNOWN'
Any solutions?
Thank you.
Most likly - you need specify full path to java.
Hint: For debugging asterisk AGI simple solution is stop asterisk and start it attached to console, that way you will see all script errors.
asterisk -rx "core stop now"
asterisk -vvvvgc
Also can be usfull enable AGI debugging in asterisk console:
agi set debug on
Check that the script and any resources it requires is owned by the Asterisk user, and that SELinux is not preventing the script from running correctly
Related
This is the code in my .conf file for asterisk freepbx I know for sure blocked is true
same => n,Noop(${Blocked})
same => n,GotoIf($["${Blocked}"=="TRUE"]?blah-ivr-v5-difficulties,s,1)
same => n,Noop("The code reaches here and doesnt hit the context at the top but its value is true")
This is the logs from asterisk saying Blocked is true
[2021-10-28 11:53:08] VERBOSE[11267][C-001e313b] pbx.c: Executing [s#blah-ivr-v5-pinreset-2:11] NoOp("SIP/blah-00245082", "true") in new stack
[2021-10-28 11:53:08] VERBOSE[11267][C-001e313b] pbx.c: Executing [s#blah-ivr-v5-pinreset-2:12] GotoIf("SIP/blah-00245082", "0?blah-ivr-v5-difficulties,s,1") in new stack
Any Idea why its not branching correctly?
Unfortanly asterisk know nothing about machine learning etc and does not think that
"true" == "TRUE"
In this case both are strings and strings with capitals not the same as lower strings(see UTF-8 table).
Even more, asterisk's boolean value is 1(integer)
https://unicode-table.com/en/
http://www.asteriskdocs.org/en/2nd_Edition/asterisk-book-html-chunk/asterisk-APP-B-89.html
https://wiki.asterisk.org/wiki/display/AST/Manipulating+Variables+Basics
I'm just trying to do a POC test with Telium's HAAst before we offer it to a customer, but I've stalled before I start the haast daemon. Currently I have a single VM with Ubuntu 16.04 LTS with Digium's basic Asterisk 13 installation. I've configured haast.conf, it seems good, but I cannot start haast daemon, it stops after a few seconds. Here is the relevant log output:
General, HAAst version 2.3.2.1 starting as daemon under process ID 2409
Controller, Local peer HAAst state changing to service start
License, License file not found. Switching to Free Edition
General, Settings contained 0 information; 0 warning; and 0 error messages.
Asterisk Controller, Unable to located executable to control Asterisk
Controller, Local peer HAAst state changing to service stop
Controller, Stopped
General, HAAst terminating with exit code 158 (failure to find asterisk control files) after running for 2 seconds
It seems, haast misses the event controller to start Asterisk daemon, unfortunately it didn't contain the installation package. I've tried to make these files (asterisk.start & asterisk.stop) based on the other sample event files, I've set the executable bit, I've wrote the shebang to the first line based on the installation guide, but nothing helped.
Is somebody experienced about this case?
Thanks, Zsolt
This error means that High Availability for Asterisk (HAAst) is unable to find the service/executable file needed to control Asterisk. Since the 'distribution' setting in the [asterisk] stanza of the haast.conf file is it to 2 (Digium Asterisk), it means there's a problem with the Asterisk service file.
Ubuntu 16 uses systemd so have you installed Digium's asterisk.service (systemd) file? If you chose to install an initd service file for Asterisk instead then you may have to explicitly tell HAAst which to look for. If you installed neither then that's your problem. The maker of HAAst (Telium) has a support forum where this topic is addressed (click here).
The pre and post Asterisk event handlers are available in the commercial versions of HAAst only - so that won't help (but it's also the wrong way to solve the problem). There are also a few Ubuntu specific topics on the support forum https://www.telium.io/haast in case that helps.
If you can't find an Asterisk systemd service file here's a sample:
[Unit]
Description=Asterisk PBX and telephony daemon
Documentation=man:asterisk(8)
Wants=network.target
After=network.target
[Service]
Type=simple
User=asterisk
Group=asterisk
ExecStart=/usr/bin/asterisk -f -C /etc/asterisk/asterisk.conf
ExecStop=/usr/bin/asterisk -rx 'core stop now'
ExecReload=/usr/bin/asterisk -rx 'core reload'
[Install]
WantedBy=multi-user.target
Just save that file as 'asterisk.service' and place in /etc/systemd/system/ and ensure permissions match other service/unit files.
Haast configuration is missing or not correct:
Unable to located executable to control Asterisk
I use call file in asterisk for auto dialing. How can I do some actions before call ? There is a predial handler in asterisk but it works with dial or followMe application. note that I'm using call file.
Make a new context to execute commands before call, for example:
[precall]
exten => _X.,1,NoOp(Precall processing)
same => n,System(echo ${EXTEN} call >> /tmp/call.log)
same => n,Dial(SIP/${EXTEN})
And then in your call file:
Channel: Local/1000#precall
Context: from-internal
Extension: 2000
In this case:
Asterisk will start in precall context at extension 1000,1
It will execute echo 1000 call >> /tmp/call.log system command
Call SIP/1000 and wait for answer
When SIP/1000 answer the call, Asterisk goes to from-internal context, extension 2000,1
If you have common configuration, it will dial number 2000
I have installed Asterisk on Ubuntu
sip.conf
[10000001]
type=friend
host=dynamic
qualify=yes
secret=pw_random
context=demo
[10000002]
type=friend
host=dynamic
qualify=yes
secret=pw_random
context=demo
...
extensions.conf
[demo]
exten => _1XXXXXXX,1,Dial(SIP/${EXTEN})
exten => _1XXXXXXX,2,Set(CALLFILENAME=${EXTEN:1})
exten => _1XXXXXXX,3,Monitor(wav,${CALLFILENAME},m)
However, Asterisk runs Dial and gets stuck, the users can talk each other on call, but Asterisk doesn't record the audio
run asterisk -rvvv, I get
-- Executing [10000001#demo:1] Dial("SIP/10000002-00000045", "SIP/10000001") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/10000001
-- SIP/10000001-00000046 is ringing
-- SIP/10000001-00000046 answered SIP/10000002-00000045
-- Channel SIP/10000002-00000045 joined 'simple_bridge' basic-bridge <1b882cee-b0f0-473f-aafb-651169788159>
-- Channel SIP/10000001-00000046 joined 'simple_bridge' basic-bridge <1b882cee-b0f0-473f-aafb-651169788159>
Any idea? Thanks!!
Update:
If I modify extensions.conf to
exten => _1XXXXXXX,1,Set(CALLFILENAME=${EXTEN})
exten => _1XXXXXXX,2,Monitor(wav,${CALLFILENAME},m)
exten => _1XXXXXXX,3,Dial(SIP/${EXTEN})
log is
-- Executing [10000001#demo:1] Set("SIP/10000002-00000000", "CALLFILENAME=10000001") in new stack
[Apr 14 00:56:50] WARNING[8649][C-00000000]: pbx.c:4910 pbx_extension_helper: No application 'Monitor' for extension (demo, 10000001, 2)
== Spawn extension (demo, 10000001, 2) exited non-zero on 'SIP/10000002-00000000'
error pbx_extension_helper: No application 'Monitor' for extension is weird.
I fixed it.
It's due to pbx_extension_helper: No application 'Monitor' for extension
Application 'Monitor' is not found because asterisk doesn't load res_monitor module according to this link
So, I add load=res_monitor.so in /etc/asterisk/modules.conf
The file looks like
[modules]
autoload=yes
load=pbx_config.so
load=chan_sip.so
load=chan_iax2.so
load=res_rtp_asterisk.so
load=app_hangup.so
load=app_dial.so
load=app_stack.so
load=res_monitor.so
load=pbx_functions.so
load=codec_ulaw.so
load=codec_gsm.so
load=bridge_simple.so
Thank Shu Zhang!
Have you checked the directory /var/lib/asterisk/sounds/, /var/spool/asterisk/monitor, or you can find your ubuntu files by your file name. Since the verbose didn't show any warning I believe you are doing this right but the recorded file is hiding somewhere. You can fix the file name .
exten => _1XXXXXXX,3,Monitor(wav,fixedfilename)
And find this file name in linux.
Moreover you can take a look of this
[a link]http://www.voip-info.org/wiki/view/Asterisk+cmd+Record
this is an old but i had the same problem, the way you solved it its correct, but you are just loading ALL MODULES... instead of making an slim module load.
[modules]
autoload=yes <---- THIS
load=pbx_config.so <---- DISABLED THIS
load=chan_sip.so
load=chan_iax2.so
So in order to make it work in a slim module load configuracion you must load
[modules]
autoload=no <---- THIS to NO
...
load=func_periodic_hook.so <---- THIS IS NEEDED IN ORDER TO LOAD MONITOR
load=load=res_monitor.so.so
...
Obviouly you need codecs and formats, here is a good slim config.
https://www.voip-info.org/asterisk-slimming/
My asterisk can move around the extension with "Goto()" but it exits immediately when meets the answer application. Could anyone help me to figure out the problem?
Executing [6138#from-sip-external:1] Goto("SIP/10.65.104.17-00000005", "kiem-tra-so-goi-vao,s,1") in new stack
-- Goto (kiem-tra-so-goi-vao,s,1)
-- Executing [s#kiem-tra-so-goi-vao:1] Answer("SIP/10.65.104.17-00000005", "") in new stack
== Spawn extension (kiem-tra-so-goi-vao, s, 1) exited non-zero on 'SIP/10.65.104.17-00000005'
Below is my dialplan:
[from-sip-external]
exten => 1234,1(dest-ext),Goto(kiem-tra-so-goi-vao,s,1)
[kiem-tra-so-goi-vao]
exten => s,1,Answer()
exten => s,n,Playback(hello-world)
exten => s,n,hangup()
Most likly you have NAT or codec issues
To get more info you have enable sip debug
asterisk -r
sip set debug on
If you see in rtp part local ips, while connection from outside, that mean you have issues with nat.
IF you see "not acceptable here", that is codec.
I guess, it should be Hangup() not hangup(). I hope that will solve the problem. If not, most likely, codec mismatch is the culprit.
Change your last line to this.
same =>n, Hangup()