Timeout 5 - good, timeout 30 - bad

I have the following setup: Asterisk 1.2.24 with a Digium PRI card. I am trying to create outgoing calls by using a call file, and I need to know the dial result, so I made setup the dial plan like this:

exten => _9.,1,Noop(${EXTEN})
exten => _9.,2,Dial(Zap/g0/${EXTEN},30,T)
exten => _9.,3,Noop(${DIALSTATUS})
exten => _9.,h,Noop(${DIALSTATUS})
exten => _9.,t,Noop(${DIALSTATUS})
exten => _9.,T,Noop(${DIALSTATUS})

exten => 1111,n,Answer()
exten => 1111,n,Playback(your-msg-has-been-saved)

The call file looks like this:
Channel: Local/9203@Dialer
MaxRetries: 0
RetryTime: 60
WaitTime: 30
Context: Dialer
Extension: 1111

I connected the computer to an Avaya IP Office so I can simulate the PRI connection and I call an extension on the Avaya. This works out fine - the call file get to the _9 extension and when it is answered it is transferred to the 1111 extension. Busy is also detected fine.

The problem starts when there is no answer - it gets nowhere. However if I change the timeout on the dial command to 5, it goes to priority 3. When I checked the CLI, with a 5 seconds timeout I get this:

-- Executing NoOp("Local/9203@Dialer-1596,2", "9203") in new stack
-- Executing Dial("Local/9203@Dialer-1596,2", "Zap/g0/9203|5|T") in new stack
-- Requested transfer capability: 0x00 - SPEECH
-- Called g0/9203
-- Zap/1-1 is ringing
-- Nobody picked up in 5000 ms
-- Hungup 'Zap/1-1'
-- Executing NoOp("Local/9203@Dialer-1596,2", "NOANSWER") in new stack

With a 30 seconds timeout I get this:
– Executing Dial(“Local/9203@Dialer-5e2e,2”, “Zap/g0/9203|30|T”) in new stack
– Requested transfer capability: 0x00 - SPEECH
– Called g0/9203
– Zap/1-1 is ringing
– Hungup ‘Zap/1-1’
== Spawn extension (Dialer, 9203, 2) exited non-zero on ‘Local/9203@Dialer-5e2e,2’

What is causing the difference and where do the dialplan eventually get to when the timeout is 30?

I just remembered there is a “failed” extension, and after adding it to the dialplan I found that any timeout of 30 and above will go to the failed extension. It is better than nothing, but failed is a global extension, and I cannot tell from where I got to it, so I need to increase the failed timeout. Is there a way?