Hangup call after Z seconds

Hi everyone,

I am looking for to implement the following situation in my asterisk dialplan:

Caller XXX calls my number YYY which is hosted on my ASTERISK.
The SIP INVITE message has a custom header with the call duration Z in seconds (eg. 300 seconds). When the call duration reach Z, Asterisk automatically Hangup the call.

Is it feasable ? How ?

Thank you.

Yes you should be able to do this.

You can read headers with the SIP_HEADER function


and you can set an absolute timeout on the call with the TIMEOUT function


Putting the two together would look like:

exten => s,n,Set(TIMEOUT(absolute)=${SIP_HEADER(X-Custom-Timeout)})

1 Like

Is posible that you need the CUT function also to get the right values from the header function

Thanks guys, is possible apply this procedure only for the time after the call are answerd?


Using local channel and Dial() command with the L(x[:y][:z]) option nd passing the value from the variable extracted from the custom header tag

Limits call duration to x milliseconds. At y ms before the maximum allowed duration, and thereafter every z ms until the end of the call, a warning is given. The x must be defined, y and z are optional. The behavior can be further controlled with the following variables: