Summary:ASTERISK-16525: AGI Hangup does not hangup channel on FastAGI
Reporter:Abeed Saleh (abeed)Labels:
Date Opened:2010-08-08 22:30:07Date Closed:2010-08-23 16:55:32
Versions:Frequency of
Environment:Attachments:( 0) agi-debug.txt
( 1) debuglog.txt
( 2) fagi.rb

Channel only gets hungup when the FastAGI server terminates the connection. Following commands don't hangup the channel:

agi: hangup
agi: hangup <channel>
exec: channel request hangup <channel>
Comments:By: Paul Belanger (pabelanger) 2010-08-09 08:06:15

We'll need a debug log, be sure to enable agi debugs.  A simple .agi script to reproduce this would help too.
We require a complete debug log to help triage the issue.

This document will provide instructions on how to collect debugging logs from an Asterisk machine for the purpose of helping bug marshals troubleshoot an issue:


By: Abeed Saleh (abeed) 2010-08-09 16:57:23

Attached are the agi log and the ruby FastAGI server. To run you need ruby 1.9, rubygems and eventmachine.

Problem is when I send the hangup agi command asterisk gives me "200 result=1" followed by "HANGUP\n" and keeps my channel open.

I Also tried to hangup the channel from cli by channel request hangup <channel> and it does not get hungup.

By: Abeed Saleh (abeed) 2010-08-13 00:38:28

Is there anything further I can provide to investigate this bug?

Thank you

By: Erin Spiceland (espiceland) 2010-08-20 15:44:17

After a softhangup, Asterisk notifies the FastAGI server that the channel is hung up and then does nothing. The expected behavior here is that the channel will stay up until the FastAGI server disconnects, after which the channel is destroyed.  In the case of an AGI script, Asterisk does send SIGHUP to the process, but a FastAGI server should handle the disconnection when it receives HANGUP.

By: Abeed Saleh (abeed) 2010-08-20 18:25:28

Dear espiceland,

Thank you for the note. The purpose of bug report was some thing else.

The problem is that FastAGI cannot hangup the channel.

Sending following AGI commands wont hangup the channel unless I completely disconnect FastAGI.
agi: hangup
agi: hangup <channel>

Also, I'm not able to hangup a channel from CLI:
channel request hangup <channel>

The only way to hangup a channel is to disconnect the FastAGI connection. AGI does not have this problem, you can hangup a channel from your AGI script.

By: Erin Spiceland (espiceland) 2010-08-20 20:58:27

That is correct.  That is the expected behavior.  "Hanging up" and destroying the channel happen at two different times.   What you are seeing is a channel that is still up but cannot be used to do anything.  Your FastAGI script is hanging up the channel, it is just not destroying the channel.  Likewise, when you issue "channel request hangup" on the CLI, the channel is hung up even if the channel is still up.  I believe you are using the word "hangup" to describe destroying a channel.

When you issue the HANGUP command from within an AGI script, Asterisk hangs up in software ("softhangup") and sends the AGI script a SIGHUP to stop the script, which disconnects the AGI connection, which causes Asterisk to destroy the channel.  Both the AGI HANGUP command and the CLI command "channel request hangup" issue a soft hangup, which tells Asterisk not to allow any more actions on the channel, like audio processing or channel variable manipulation, but when using FastAGI the channel is not destroyed until the FastAGI script disconnects, and this is done on purpose.  Basically, this is a "best practice" scenario. The developer should always disconnect from within the FastAGI server or script after issuing the HANGUP command.