Asterisk GOTOIf Command not hitting branch correctly - asterisk

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

Related

Asterisk dialplan - waitexten hangs up immediately and does not wait

Consider the following asterisk dialplan. After the last sound file is played it hangs up immediately and the waitexten timeout parameter seems to be ignored. The behaviour I am trying to achieve is to wait a given number of seconds after the last sound file is completed to get a response and then hang up. The last sound file says "Dial * to hear these options again". If I set the waitexten timeout to say 60, it hangs up before the sound files are played. A shorter time allows them all to be played but then it hangs up immediately. Any suggestions for handling this a better way are welcome
[mainmenu]
exten => s,1,Wait(0.25)
same => 2,Answer()
same => 3,Background(/srv/asterisk/sounds/optionslist)
same => n,Background(/srv/asterisk/sounds/dial2cs)
same => n,Background(/srv/asterisk/sounds/dial3ma)
same => n,Background(/srv/asterisk/sounds/dial4ac)
same => n,Background(/srv/asterisk/sounds/dial0)
same => n,Background(/srv/asterisk/sounds/dialstar)
same => n,WaitExten(20)
exten => 2,1,Goto(cs,2,1)
exten => *,1,Goto(s,3)
console output
== Using SIP RTP CoS mark 5
-- Executing [+12345#public:1] Goto("SIP/xxx.pstn.twilio.com-00000044", "mainmenu,s,1") in new stack
-- Goto (mainmenu,s,1)
-- Executing [s#mainmenu:1] Wait("SIP/xxx.pstn.twilio.com-00000044", "0.25") in new stack
-- Executing [s#mainmenu:4] BackGround("SIP/xxx.pstn.twilio.com-00000044", "/srv/asterisk/sounds/dial2cs") in new stack
-- Executing [s#mainmenu:5] BackGround("SIP/xxx.pstn.twilio.com-00000044", "/srv/asterisk/sounds/dial3ma") in new stack
-- <SIP/xxx.pstn.twilio.com-00000044> Playing '/srv/asterisk/sounds/dial3ma.slin' (language 'en')
-- Executing [s#mainmenu:6] BackGround("SIP/xxx.pstn.twilio.com-00000044", "/srv/asterisk/sounds/dial4ac") in new stack
-- <SIP/xxx.pstn.twilio.com-00000044> Playing '/srv/asterisk/sounds/dial4ac.slin' (language 'en')
-- Executing [s#mainmenu:7] BackGround("SIP/xxx.pstn.twilio.com-00000044", "/srv/asterisk/sounds/dial0") in new stack
-- <SIP/xxx.pstn.twilio.com-00000044> Playing '/srv/asterisk/sounds/dial0.slin' (language 'en')
-- Executing [s#mainmenu:8] BackGround("SIP/xxx.pstn.twilio.com-00000044", "/srv/asterisk/sounds/dialstar") in new stack
-- <SIP/xxx.pstn.twilio.com-00000044> Playing '/srv/asterisk/sounds/dialstar.slin' (language 'en')
[
[Aug 4 05:03:28] WARNING[2225]: chan_sip.c:4175 retrans_pkt: Retransmission timeout reached on transmission xxx#0.0.0.0 for seqno 5305 (Critical Response) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 32001ms with no response
[Aug 4 05:03:28] WARNING[2225]: chan_sip.c:4204 retrans_pkt: Hanging up call xxx#0.0.0.0 - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).
== Spawn extension (mainmenu, s, 8) exited non-zero on 'SIP/xxx.pstn.twilio.com-00000044'
Asterisk 11.7.0~dfsg-1ubuntu1
I assume that you have a problem like in this topic Asterisk,SIP Retransmission timeout. Try to solve the problem with the NAT settings or firewall.
In this answer propose to set canreinvite=no in sip.conf.

Dcm4che Error Unrecognized PDU

I have the following error in a data retrieve on a Dcm4che Server:
2015-04-27 14:55:16,463 ERROR -> (TCPServer-1-2) [org.dcm4cheri.server.ServerImpl] org.dcm4che.net.PDUException: Unrecognized PDU[type=71, length=14113
95360]
org.dcm4che.net.PDUException: Unrecognized PDU[type=71, length=1411395360]
at org.dcm4cheri.net.FsmImpl$2.parse(FsmImpl.java:1051)
at org.dcm4cheri.net.FsmImpl.read(FsmImpl.java:512)
at org.dcm4cheri.net.AssociationImpl.accept(AssociationImpl.java:287)
at org.dcm4cheri.server.DcmHandlerImpl.handle(DcmHandlerImpl.java:248)
at org.dcm4cheri.server.ServerImpl.run(ServerImpl.java:288)
at org.dcm4cheri.util.LF_ThreadPool.join(LF_ThreadPool.java:174)
at org.dcm4cheri.util.LF_ThreadPool$1.run(LF_ThreadPool.java:221)
at java.lang.Thread.run(Thread.java:662)
Can somebody help me please?
Likely a mismatch in aet name or settings.
Imagine your dcmrcv server as a house. It has a mailbox address that is just listening for stuff.
Now when you use say dcmsnd from somewhere else you must make sure it sends its information to the correct address. If you get ip and port right you may see a blurb come out on dcmrcv but it won't accept it.
Simplify your test as much as possible. Here is a very simple dcmrcv:
dcmrcv TRANSFERTEST#10.1.50.75:104 -dest "C:\Temp"
call this from another cmd prompt:
dcmsnd CONI_STORAGE#dev.capsurecloud.com:11012 "C:\modalities\xa" -L WST
Note: That WST is not needed, but is the aet name of my application. Read the confluence documentation for more arguments.
Most the time i see your error is becuase the aetname#ip is mismatch or one side is sending or listening for tls and the other side doesn't match.

How to record friend call on Asterisk

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/

Symfony2 get error code for flush function

I am using Symfony and creating a soft with 3 tiers (client, apache, mysql). So I don't know how to get the statut when the symfony application persists and flushs something?
When I add something in database I display an alert like "Add done!" but if my database is down I will display "Add done" despite the fail...
So how can I get the statut of these functions (flush/persist)? How can I change my alert switch the statut?
Best regards,
Use a try & catch block:
try {
$article = new Article(); //Example entity
$em = $this->getDoctrine()->getEntityManager();
$em->persist($article);
$em->flush();
$this->get('session')->setFlash('flash_key',"Add done!");
} catch (Exception $e) {
$this->get('session')->setFlash('flash_key',"Add not done: " . $e->getMessage());
}
In case you get errors try using "\Doctrine\ORM\ORMException $e", \Doctrine\DBAL\DBALException $e" or "\Exception $e" inside catch()
My issue was that I was passing a complex object into a field that expected a string even though I had set that column up to be a ManyToOne. Apparently #ORM\Column overrode that.
However! It's not what the error was that's interesting, it's how I fixed it.
I was having a PDOException. I had to deep dive into the code with xdebug and PHPStorm. xdebug is supported by many PHP IDEs. xdebug is tough to set up the first several times that you set it up. There's always some firewall hassle or hassle getting it to show up in your phpinfo() or xdebug.enable_remote or xdebug.remote_host.
Get used to it. JUST DO IT! No seriously. Don't write another line of code in PHP until you have got xdebug working; even if you run into 8 million issues. You will save years of your life in coding.
I don't know about Symfony, but ZF3 now comes with a Vagrantfile. You install vagrant and Oracle VirtualBox, type vangrant up in your Zf3 project directory, and you have a fully-functional local web server running your ZF3 application at http://localhost:8080. From there all I had to do was:
... Well first, before I called vagrant up for the first time, I added the following line to the Vagrantfile
config.vm.network "private_network", ip: "192.168.33.10" ... then I called vagrant up
vangrant ssh
sudo -s
apt-get install php-xdebug
echo "xdebug.remote_enable = 1" >> /etc/php/7.0/apache2/php.ini
echo "xdebug.remote_host = 192.168.33.1" >> /etc/php/7.0/apache2/php.ini
apachectl restart
In your phpinfo(), you should see xdebug somwhere. Just ctrl + f for it. If it's there, you're mostly in business.
Then I added a rule for port 9000 on my firewall. Then I started an xdebug session. If it doesn't work You can temporarily shut down Windows Firewall just to check if it works, but remember to enable it right away and make sure it's not just the firewall. Setup a firewall rule for incoming on port 9000 and allow ip 192.168.33.10. If you don't know how to do this ... why are you trying to develop web software?
Learn to use xdebug!!!

AGI script executes without error , but no results generated

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

Resources