I have an Asterisk app that receives calls via IAX and hands it off to an AGI written in Perl. It immediatly greets inbound callers by saying something like “Hello, welcome to blah blah blah…”. The problem is that the the AGI seems to start before the call is completely connected. THe user usually misses the first few words of the introductory prompt. I have worked around the problem in the past by putting in a sleep(1) in the Perl script, but I hate the unnecessary delay. It only happens in production when the call is coming in from ipcomms.net. It never happens when I connect via IDEFISK in either production or test environments. What can I do to fix this?
Here are the important parts of the Asterisk app:
exten => s,1,Set(TIMEOUT(absolute)=3900)
exten => s,2,AGI(HandleCall.pl)
exten => s,3,Hangup()
HandleCall.pl AGI App -------------------
It gets the AGI parameters, tells Asterisk to ANSWER, and almost immediately does a STREAM FILE.