Upgrade 3CX to v18 and get it hosted free!

Asterisk Cmd Hangup

Author image

Synopsis:

Hangup(<causecode>)

Description:

This application hangs up the calling channel unconditionally and returns -1. If a causecode is given the channel’s hangup cause is set to the given value.

For SIP Connections

It is possible to send different reply errors (“404 Not found”, “484 Address incomplete” etc.) by setting <causecode> to one of the values defined by RFC 3398 – page 24.

The <causecode> parameter is the ISDN causecode and not the SIP response code. For example, to hang up a call with the SIP cause 503, the dialplan must execute hangup(42).

When call is hung up, Asterisk sends the extra SIP header “X-Asterisk-HangupCauseCode” in the BYE message.

For PRI Connections: Setting a PRI_CAUSE

Available on CVS versions March, 2004

On Zap PRI channels it is possible to set the PRI_CAUSE variable prior to Hangup(). This sends a PRI DISCONNECT message with the set CAUSE element to the switch. Some commonly used cause codes:

  • 1 = Unallocated number
  • 16 = Normal call clearing
  • 17 = User busy
  • 18 = No user responding (telephone device not connected)
  • 21 = Call rejected
  • 22 = Number changed
  • 27 = Destignation out of order
  • 38 = Network out of order
  • 41 = Temporary failure

In Canada, through Group Telecom (May work through others) The hangup with PRI_CAUSE delivers these messages.

  • PRI_CAUSE = 0,22,28,65-66 We’re sorry your call cannot be completed as dialed, please contact the group telecom customer service center at 1-877-484-5101 if you require assistance.
  • PRI_CAUSE = 2-16,19-20,23-27,29-40,43-53,55-64,67-100 Fast Busy Signal / Congestions
  • PRI_CAUSE = 17,41 Slow Busy Signal (Normal busy signal you hear every day)
  • PRI_CAUSE = 18,21 Ringing (Normal ringing you hear every day)
  • PRI_CAUSE = 42,54 We’re sorry, all circuits are busy, please try your call again later.

Example:

exten => i,1,SetVar(PRI_CAUSE=1); only needed for older Asterisk versions
; invalid extension dialed - PRI_CAUSE=unallocated number
exten => i,2,Hangup ; Outdated: Asterisk 1.4 allows to transmit the cause code as argument to Hangup()
; send the DISCONNECT message
; This results in most cases in a network generated recording like
"The number you have dialed has been disconnected ..."

See Also


Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.