On Mon, 7 Jun 2010, Adil Zaaraoui wrote:

I tried your statement in my extension like this:

("context" or "dialplan" would be "more correct" than "extension.")

  exten = 777,n,                  set(TIMEOUT(absolute)=10)
  exten = 777,n,                  dial(iax2/400)
  exten = 777,n,                  hangup()

If peer (400) answers the call the call persists, no autohangup is made after 10 senconds (absolute timeout), but the if peer does not hangup, it rings for 10 seconds and stops.

This is unexpected. When the absolute timer expires, the call should "jump" to the "T" extension in the context. If there isn't a "T" extension, the call should hang up.

Please use a "goto(absolute-timeout-test,777,1)" to execute the following context with the CLI verbosity set to at least 3:

[absolute-timeout-test]
        exten = T,1,                    verbose(1,[${CONTEXT}:${EXTEN}])
        exten = T,n,                    hangup()

        exten = h,1,                    verbose(1,[${CONTEXT}:${EXTEN}])
        exten = h,n,                    hangup()

        exten = 777,1,                  verbose(1,[${CONTEXT}:${EXTEN}])
        exten = 777,n,                  set(TIMEOUT(absolute)=10)
        exten = 777,n,                  dial(sip/201)
        exten = 777,n,                  hangup()

And compare your console output to:

 [absolute-timeout-test:777]
    -- Executing Set("SIP/501-090e8700", "TIMEOUT(absolute)=10") in new stack
    -- Channel will hangup at 2010-06-07 15:34:29 UTC.
    -- Executing Dial("SIP/501-090e8700", "sip/201") in new stack
    -- Called 201
    -- SIP/201-0910b9a8 is ringing
    -- SIP/201-0910b9a8 answered SIP/501-090e8700
    -- Attempting native bridge of SIP/501-090e8700 and SIP/201-0910b9a8
  == Spawn extension (absolute-timeout-test, 777, 3) exited non-zero on 
'SIP/501-090e8700'
    -- Executing Verbose("SIP/501-090e8700", "1|[absolute-timeout-test:T]") in 
new stack
 [absolute-timeout-test:T]
    -- Executing Hangup("SIP/501-090e8700", "") in new stack
  == Spawn extension (absolute-timeout-test, T, 2) exited non-zero on 
'SIP/501-090e8700'
    -- Executing Verbose("SIP/501-090e8700", "1|[absolute-timeout-test:h]") in 
new stack
 [absolute-timeout-test:h]
    -- Executing Hangup("SIP/501-090e8700", "") in new stack
  == Spawn extension (absolute-timeout-test, h, 2) exited non-zero on 
'SIP/501-090e8700'

I'm calling from SIP/501 to SIP/201, but your output should be similar.

While following the console output, I realize this solution may not do what you want. The absolute timer starts counting when it is set, not when the peer answers the call. I don't know if this difference is important to your application.

Looking at the dial application options again, there is "S(x) - Hang up the call after 'x' seconds *after* the called party has answered the call." This may be more appropriate for you. I'd still recommend looking up the peer and duration in the AGI, set channel variables, and then do the dial command in the dialplan.

"Are you saying that when you execute the dial application from your AGI Asterisk dials the peer and when peer answers they get dead air for 13 seconds before being bridged with the caller?"

No, the communication is up we hear each other, but the satament System.out.println("after dial app") which is just after exec("dial.... is executed after about 13 seconds, and sometimes not, the dial blocks the script to continue.

Going back to a previous email where you asked what I meant about it being easy to violate the AGI protocol:

The AGI protocol is implemented by issuing requests and receiving responses via STDOUT and STDIN respectively. (FastAGI uses network sockets.)

Most programmer's first "fail" is not reading the AGI environment from STDIN first. Next, they fail to realize that for every request, they must read the response. Lastly, they try to debug their AGI by reading something from STDIN or writing something to STDOUT, not remembering that STDIN and STDOUT are "connected" to Asterisk, not their console.

I always recommend that programmers use an existing library rather than developing their own. The chance of success is much higher.

Most AGI problems I have seen (mine and others) can be resolved by understanding the above and enabling AGI debugging on the console and observing the output.

I'm not a Java programmer, but "System.out.println()" sounds like writing something to STDOUT to me. If you are still executing your AGI via FastAGI ("agi://") this may not apply.

Note that I say "AGI" not "script." An AGI can (and should IMHO) be written in a compiled language like C.

How to set the channel variable in the AGI script??

This depends on your AGI library. There should be a function or method that ends up sending "set variable x y" to Asterisk.

--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       sedwa...@sedwards.com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000
-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to