[Home]

Summary:ASTERISK-17124: Asterisk does not hangup a channel after endpoint hangs up when using FastAGI
Reporter:Claudio Villalobos (devmod)Labels:
Date Opened:2010-12-16 21:11:03.000-0600Date Closed:2011-04-13 11:37:09
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) dialplan.rb
( 1) extensions.conf
( 2) extra.log
( 3) log_18492.txt
( 4) sip.conf
Description:When an existing call being handled by an AGI script its hung up, asterisk waits until that application returns to hang up the channel.
From the info I gathered @ #asterisk-dev, Asterisk should send 'HANGUP' to the AGI script right along/after a command response. This does not happen and the channel is never hung -unless the script returns-.

I am using adhearsion and a very simple dialplan.
Comments:By: Leif Madsen (lmadsen) 2010-12-20 08:53:08.000-0600

Actually I could see this as being a feature the way it exists now. I may actually want my script to finish executing before the call is hung up.

This sounds like some functionality needs to be added to permit the selection (via a flag to AGI()) to control whether the script should return immediately upon channel hangup, or finish executing first.

By: Ben Klang (bklang) 2011-02-11 12:13:36.000-0600

The issue isn't that the socket stays open, it is that Asterisk never signals the hangup to the AGI process.

Here's a simple example:

DEBUG agi: >>> ANSWER
DEBUG agi: <<< 200 result=0

DEBUG agi: >>> EXEC Wait "5"
**** Caller attached to AGI hangs up here; Wait returns -1
DEBUG agi: <<< 200 result=-1

DEBUG agi: >>> EXEC Wait "5"
DEBUG agi: <<< 200 result=0
**** This response is wrong.  It should be "511 Command not permitted on a dead channel" or simply "HANGUP"


The problem is that the AGI script has no way of knowing that the remote end has hung up and so continues processing indefinitely.  Because the AGI socket is open, Asterisk leaves the channel in a zombie state until the AGI process is killed.

Tested on Asterisk SVN branch 1.8 r306529



By: Richard Mudgett (rmudgett) 2011-04-08 13:08:21

The issue17954_v1.8.patch file is the patch on reviewboard.

By: Digium Subversion (svnbot) 2011-04-13 11:21:29

Repository: asterisk
Revision: 313545

U   branches/1.4/main/channel.c
U   branches/1.4/res/res_agi.c

------------------------------------------------------------------------
r313545 | rmudgett | 2011-04-13 11:21:26 -0500 (Wed, 13 Apr 2011) | 41 lines

Asterisk does not hangup a channel after endpoint hangs up.

If the call that the dialplan started an AGI script for is hungup while
the AGI script is in the middle of a command then the AGI script is not
notified of the hangup.  There are many AGI Exec commands that this can
happen with.  The reported applications have been: Background, Wait, Read,
and Dial.  Also the AGI Get Data command.

* Don't wait on the Asterisk channel after it has hung up.  The channel is
likely to never need servicing again.

* Restored the AGI script's ability to return the AGI_RESULT_HANGUP value
in run_agi().  It previously only could return AGI_RESULT_SUCCESS or
AGI_RESULT_FAILURE after the DeadAGI and AGI applications were merged.

(closes issue ASTERISK-16649)
Reported by: mn3250
Patches:
     issue17954_v1.8.patch uploaded by rmudgett (license 664)
     issue17954_v1.6.2.patch uploaded by rmudgett (license 664)
     issue17954_v1.4.patch uploaded by rmudgett (license 664)
Tested by: rmudgett
JIRA SWP-2171

(closes issue ASTERISK-17124)
Reported by: devmod
Tested by: rmudgett
JIRA SWP-2761

(closes issue ASTERISK-17520)
Reported by: nvitaly
Tested by: astmiv, rmudgett
JIRA SWP-3216

(closes issue ASTERISK-16144)
Reported by: siby
Tested by: rmudgett
JIRA SWP-2727

Review: https://reviewboard.asterisk.org/r/1165/

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=313545

By: Digium Subversion (svnbot) 2011-04-13 11:29:53

Repository: asterisk
Revision: 313579

_U  branches/1.6.2/
U   branches/1.6.2/main/channel.c
U   branches/1.6.2/res/res_agi.c

------------------------------------------------------------------------
r313579 | rmudgett | 2011-04-13 11:29:51 -0500 (Wed, 13 Apr 2011) | 48 lines

Merged revisions 313545 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
 r313545 | rmudgett | 2011-04-13 11:21:24 -0500 (Wed, 13 Apr 2011) | 41 lines
 
 Asterisk does not hangup a channel after endpoint hangs up.
 
 If the call that the dialplan started an AGI script for is hungup while
 the AGI script is in the middle of a command then the AGI script is not
 notified of the hangup.  There are many AGI Exec commands that this can
 happen with.  The reported applications have been: Background, Wait, Read,
 and Dial.  Also the AGI Get Data command.
 
 * Don't wait on the Asterisk channel after it has hung up.  The channel is
 likely to never need servicing again.
 
 * Restored the AGI script's ability to return the AGI_RESULT_HANGUP value
 in run_agi().  It previously only could return AGI_RESULT_SUCCESS or
 AGI_RESULT_FAILURE after the DeadAGI and AGI applications were merged.
 
 (closes issue ASTERISK-16649)
 Reported by: mn3250
 Patches:
       issue17954_v1.8.patch uploaded by rmudgett (license 664)
       issue17954_v1.6.2.patch uploaded by rmudgett (license 664)
       issue17954_v1.4.patch uploaded by rmudgett (license 664)
 Tested by: rmudgett
 JIRA SWP-2171
 
 (closes issue ASTERISK-17124)
 Reported by: devmod
 Tested by: rmudgett
 JIRA SWP-2761
 
 (closes issue ASTERISK-17520)
 Reported by: nvitaly
 Tested by: astmiv, rmudgett
 JIRA SWP-3216
 
 (closes issue ASTERISK-16144)
 Reported by: siby
 Tested by: rmudgett
 JIRA SWP-2727
 
 Review: https://reviewboard.asterisk.org/r/1165/
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=313579

By: Digium Subversion (svnbot) 2011-04-13 11:31:53

Repository: asterisk
Revision: 313588

_U  branches/1.8/
U   branches/1.8/main/channel.c
U   branches/1.8/res/res_agi.c

------------------------------------------------------------------------
r313588 | rmudgett | 2011-04-13 11:31:51 -0500 (Wed, 13 Apr 2011) | 55 lines

Merged revisions 313579 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

................
 r313579 | rmudgett | 2011-04-13 11:29:49 -0500 (Wed, 13 Apr 2011) | 48 lines
 
 Merged revisions 313545 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r313545 | rmudgett | 2011-04-13 11:21:24 -0500 (Wed, 13 Apr 2011) | 41 lines
   
   Asterisk does not hangup a channel after endpoint hangs up.
   
   If the call that the dialplan started an AGI script for is hungup while
   the AGI script is in the middle of a command then the AGI script is not
   notified of the hangup.  There are many AGI Exec commands that this can
   happen with.  The reported applications have been: Background, Wait, Read,
   and Dial.  Also the AGI Get Data command.
   
   * Don't wait on the Asterisk channel after it has hung up.  The channel is
   likely to never need servicing again.
   
   * Restored the AGI script's ability to return the AGI_RESULT_HANGUP value
   in run_agi().  It previously only could return AGI_RESULT_SUCCESS or
   AGI_RESULT_FAILURE after the DeadAGI and AGI applications were merged.
   
   (closes issue ASTERISK-16649)
   Reported by: mn3250
   Patches:
         issue17954_v1.8.patch uploaded by rmudgett (license 664)
         issue17954_v1.6.2.patch uploaded by rmudgett (license 664)
         issue17954_v1.4.patch uploaded by rmudgett (license 664)
   Tested by: rmudgett
   JIRA SWP-2171
   
   (closes issue ASTERISK-17124)
   Reported by: devmod
   Tested by: rmudgett
   JIRA SWP-2761
   
   (closes issue ASTERISK-17520)
   Reported by: nvitaly
   Tested by: astmiv, rmudgett
   JIRA SWP-3216
   
   (closes issue ASTERISK-16144)
   Reported by: siby
   Tested by: rmudgett
   JIRA SWP-2727
   
   Review: https://reviewboard.asterisk.org/r/1165/
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=313588

By: Digium Subversion (svnbot) 2011-04-13 11:37:09

Repository: asterisk
Revision: 313606

_U  trunk/
U   trunk/main/channel.c
U   trunk/res/res_agi.c

------------------------------------------------------------------------
r313606 | rmudgett | 2011-04-13 11:37:06 -0500 (Wed, 13 Apr 2011) | 62 lines

Merged revisions 313588 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
 r313588 | rmudgett | 2011-04-13 11:31:50 -0500 (Wed, 13 Apr 2011) | 55 lines
 
 Merged revisions 313579 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.6.2
 
 ................
   r313579 | rmudgett | 2011-04-13 11:29:49 -0500 (Wed, 13 Apr 2011) | 48 lines
   
   Merged revisions 313545 via svnmerge from
   https://origsvn.digium.com/svn/asterisk/branches/1.4
   
   ........
     r313545 | rmudgett | 2011-04-13 11:21:24 -0500 (Wed, 13 Apr 2011) | 41 lines
     
     Asterisk does not hangup a channel after endpoint hangs up.
     
     If the call that the dialplan started an AGI script for is hungup while
     the AGI script is in the middle of a command then the AGI script is not
     notified of the hangup.  There are many AGI Exec commands that this can
     happen with.  The reported applications have been: Background, Wait, Read,
     and Dial.  Also the AGI Get Data command.
     
     * Don't wait on the Asterisk channel after it has hung up.  The channel is
     likely to never need servicing again.
     
     * Restored the AGI script's ability to return the AGI_RESULT_HANGUP value
     in run_agi().  It previously only could return AGI_RESULT_SUCCESS or
     AGI_RESULT_FAILURE after the DeadAGI and AGI applications were merged.
     
     (closes issue ASTERISK-16649)
     Reported by: mn3250
     Patches:
           issue17954_v1.8.patch uploaded by rmudgett (license 664)
           issue17954_v1.6.2.patch uploaded by rmudgett (license 664)
           issue17954_v1.4.patch uploaded by rmudgett (license 664)
     Tested by: rmudgett
     JIRA SWP-2171
     
     (closes issue ASTERISK-17124)
     Reported by: devmod
     Tested by: rmudgett
     JIRA SWP-2761
     
     (closes issue ASTERISK-17520)
     Reported by: nvitaly
     Tested by: astmiv, rmudgett
     JIRA SWP-3216
     
     (closes issue ASTERISK-16144)
     Reported by: siby
     Tested by: rmudgett
     JIRA SWP-2727
     
     Review: https://reviewboard.asterisk.org/r/1165/
   ........
 ................
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=313606

By: David Cunningham (dcunningham) 2011-06-20 06:58:37.904-0500

We are having this issue on Asterisk 1.8.4.2, eg:

[Jun 20 13:56:49] VERBOSE[22068] res_agi.c: <SIP/ens-local-0001413c>AGI Rx << WAIT FOR DIGIT 1000
[Jun 20 13:56:49] VERBOSE[22068] res_agi.c: <SIP/ens-local-0001413c>AGI Tx >> 511 Command Not Permitted on a dead channel
[Jun 20 13:56:49] VERBOSE[22068] res_agi.c: <SIP/ens-local-0001413c>AGI Rx << VERBOSE "wait_for_digit returned 0." 9

Can you please advise what other information you need? Thanks.