[Asterisk-Users] 2 leg bridged call not hanging up until both legs hangup

Aaron Bostick Aaron.Bostick at dandsltd.com
Mon Dec 5 21:50:08 MST 2005


Hello everyone,

I am somewhat new to asterisk but am hoping someone can help me.  I have
an application that sends the following commands to asterisk's telnet
port:

Action: Originate
Channel: Zap/g1/5551239876
Timeout: 30000
Context: from-agent
Exten: 5559871234
Priority: 1
Variable: call_id=00001234
Variable: origination=5551239876

This causes the 5551239876 number to be called and when the agent
answers, the extension number is called from the dial plan and the two
calls are bridged.  The dial plan to do this looks like this:

[from-agent]
exten => _X.,1,Answer()
exten => _X.,n,AGI(route_call.php)
exten => _X.,n,SetCIDNum(${GATEWAY_NUMBER})
exten => _X.,n,Monitor(wav,${CALL_ID},b)
exten => _X.,n,Dial(Zap/g1/${EXTEN},,HM(setchannel^${CALL_ID}))
exten => _X.,n,Hangup()
exten => t,1,Hangup()
exten => i,1,Hangup()
exten => h,1,StopMonitor()
exten => h,n,SoftHangup(${CHANNEL})
exten => h,n,SoftHangup(${BRIDGEPEER})
exten => h,n,System(/usr/bin/soxmix
/var/spool/asterisk/monitor/${CALL_ID}-in.wav
/var/spool/asterisk/monitor/${CALL_ID}-out.wav
/var/spool/asterisk/monitor/${CALL_ID}.wav)
exten => h,n,System(/usr/bin/lame -b 16
/var/spool/asterisk/monitor/${CALL_ID}.wav
/var/recordings/${CALL_ID}.mp3)
exten => h,n,System(/bin/rm -rf
/var/spool/asterisk/monitor/${CALL_ID}*.wav)
exten => h,n,DeadAGI(cleanup_call.php)

The call is monitored once the bridge starts and after hangup converted
to an mp3 and that all works great.

The problem I am having is the call and recording continues after the
agent hangs up their phone until the extension number hangs up their
phone.  This is especially evident when an answering machine/voicemail
is called and the call recording can last from 10 to 60 seconds beyond
the real person hanging up depending on how long the answering machine
stays on the line.

All of the hangup commands in the dial plan are futile attempts to
shorten this time.  What I am really looking for is for the 2nd leg of
the call to be forcibly hung up whenever the first leg of the call is
detected as hung up so my dial plan execution can continue.

I would imagine this would have to be something in the "bridging" code
but there doesn't seem to be a bridge command, only the Dial command.
Any thoughts?!  Thanks so much.

Aaron Bostick



More information about the asterisk-users mailing list