[1.4] Trouble with "h" extension


I reread the relevant chapters in the Third edition of “Asterisk: The Definitive Guide”, but didn’t find the answer to explain this behavior.

In the following extension.conf, in the “h” extension…

  1. The Wait(10) doesn’t wait 10 seconds, but simply just ends the call
  2. The second line, which calls an AGI script, isn’t run, so I never get to that part
exten => s,1,Wait(3)
exten => s,n,Set(CID=${CALLERID(num)})
exten => s,n,Hangup

;Doesn't wait 10s, and doesn't call script
exten => h,1,Wait(10)
exten => h,n,AGI(/var/tmp/myscript.sh,${CID})

Here’s the output from the console:

-- Starting simple switch on 'Zap/1-1'
-- Executing [s@from_fxo:1] Wait("Zap/1-1", "3") in new stack
-- Executing [s@from_fxo:2] Set("Zap/1-1", "CID=123456") in new stack
-- Executing [s@from_fxo:3] Hangup("Zap/1-1", "") in new stack
== Spawn extension (from_fxo, s, 3) exited non-zero on 'Zap/1-1'
-- Executing [h@from_fxo:1] Wait("Zap/1-1", "10") in new stack
== Spawn extension (from_fxo, h, 1) exited non-zero on 'Zap/1-1'
-- Hungup 'Zap/1-1'

The goal is to have Asterisk call me back on my cellphone, so I figured going from the “s” to “h” extension was the right way to do this. Does someone know why Asterisk is behaving that way instead of what I expected?

Thank you.

Wait for quite reasonable reasons can detect a hangup. As the line is already hungup, it will detect it immediately! Applicatons that detect hangup generally signal the dialplan to terminate.

Thanks David. Makes sense. I’ll just use a Wait/Sleep in the script to pause before proceeding.

However, what about the second line? Why does Asterisk not call the AGI script?

Because Wait exited with a non-zero return code because of the hangup.

Note you will have to use Dead AGI on some versions. I’m not sure when that ceased to be necessary.

Thanks again.