Summary: | ASTERISK-30102: Hangup_handler not invoked | ||
Reporter: | Morten Sølvberg (Soelvberg) | Labels: | |
Date Opened: | 2022-06-08 10:01:33 | Date Closed: | 2022-06-10 07:21:58 |
Priority: | Minor | Regression? | |
Status: | Closed/Complete | Components: | Bridges/bridge_simple |
Versions: | 18.0.1 | Frequency of Occurrence | Constant |
Related Issues: | |||
Environment: | Hosted in Azure | Attachments: | |
Description: | I am recording calls with MixMonitor, and I am using "hangup_handler_push" on all calls I crate/receive, to make sure that the calls are always sent to the same location in the dialplan where I move the recording to a mounted drive.
This usually works fine, but I see that when I use the Bridge application, then the hangup_handler is removed for the *Briged* party. I assume that this happens due to the masquerade functionality in Asterisk, and that the hangup_handler isn't copied to the new channel. I can see the hangup_handler being invoked on the Surrogate channel, but not on the actual one. Luckily I can use the F option in the Bridge application, so the *Bridged* party is sent to defined place in the dialplan when the *Bridger* hangs up. This also works fine. However if the *Bridged* party hangs up, then the channel is not sent to the defined localion in the dialplan. I have an h extension in all the the contexts that the channel has been in, but it does not hit any of these either. Is this a known issue and/or can you think of a workaround? | ||
Comments: | By: Asterisk Team (asteriskteam) 2022-06-08 10:01:33.738-0500 Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution. Please note that log messages and other files should not be sent to the Sangoma Asterisk Team unless explicitly asked for. All files should be placed on this issue in a sanitized fashion as needed. A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report. Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process]. Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur. Please note that by submitting data, code, or documentation to Sangoma through JIRA, you accept the Terms of Use present at [https://www.asterisk.org/terms-of-use/|https://www.asterisk.org/terms-of-use/]. By: Kevin Harwell (kharwell) 2022-06-08 15:29:07.501-0500 Please post steps to replicate, and include the dialplan (or sample dialplan) involved, e.g. setting the hangup handler, using Bridge app, etc... Thanks! By: Morten Sølvberg (Soelvberg) 2022-06-09 03:44:57.027-0500 Hi Kevin The actual Diaplan is very complex, but the below example will show it just as well. 'Channel1' and 'Channel2' both dials 1234, is assigned a hangup_handler and placed in a queue. 'Channel1' is then redirected via AMI to the BridgeChannels context and orders a bridge with 'Channel2'. If you look at the log you will see that the the hangup action [chanHungUp] is perfomed immidiately for the chanel 'Surrogate/Channel2', but is not performed when 'Channel2' leaves the bridge. Futher more you will see that if 'Channel2' is the first to hangUp, then it is not sent to (bridgedEnd,s,1) as ordered in the Bridge application, and does no show up as the h extension in any other part of the dial plan. I believe that the actual error is that the hangup_handler isn't copied to the new channel when the Masquerade operation ís performed. The second problem where the channel isn't sent to (bridgedEnd,s,1) when it hangs up, might have been the actual intent, and that you therefore won't see this as an error - which is fine. [IncomingContext] exten => 1234,1,Answer() exten => 1234,n,Gosub(hanguphandler,s,1) exten => 1234,n,Queue(SomeQueue) exten => h,1,Goto(chanHungUp,s,1) [hanguphandler] exten => s,1,Set(CHANNEL(hangup_handler_push)=chanHungUp,s,1()); exten => s,n,Return() __________________________ Send this via AMI: Action: SetVar Channel: FirstChannel Variable: IdOfOtherChannel Value: SecondChannel Action: Redirect Channel: FirstChannel Context: BridgeChannels Exten: s Priority: 1 __________________________ [BridgeChannels] exten => s,1,Bridge(${IdOfOtherChannel},F(bridgedEnd,s,1)) exten => s,n,NoOp(bridger exit - BRIDGERESULT = ${BRIDGERESULT}) exten => s,n,HangUp() exten => h,1,Goto(chanHungUp,s,1) [bridgedEnd] exten => s,1,NoOp(bridged exit) exten => s,n,HangUp() exten => h,1,Goto(chanHungUp,s,1) [chanHungUp] exten => s,1,NoOp(Channel now hung up); exten => s,n,Return() By: Morten Sølvberg (Soelvberg) 2022-06-09 03:51:28.716-0500 Sorry about the extra linebreaks in the example but I assume that it is added by your editor when writing curly brackets... By: Kevin Harwell (kharwell) 2022-06-09 13:29:59.435-0500 Unless I misunderstand it appears the hangup handler for me remains. I'm using the following dialplan. I've based it off or your's, but modified it some to make it easier for me to see what channel is hanging up and where: {noformat} [default] exten => 940,1,NoOp() same => n,Answer() same => n,Playback(demo-congrats) same => n,Hangup() exten => 150,1,NoOp() same => n,Answer() same => n,Verbose(0, Answered: ${CHANNEL}) same => n,Set(GLOBAL(Channel1)=${CHANNEL}) same => n,Verbose(0, Add hangup handler to: ${CHANNEL}) same => n,Set(CHANNEL(hangup_handler_push)=ChannelHungup1,s,1()) same => n,Echo() same => n,Hangup() exten => 151,1,NoOp() same => n,Answer() same => n,Verbose(0, Answered: ${CHANNEL}) same => n,Set(GLOBAL(Channel2)=${CHANNEL}) same => n,Verbose(0, Add hangup handler to: ${CHANNEL}) same => n,Set(CHANNEL(hangup_handler_push)=ChannelHungup2,s,1()) same => n,Echo() same => n,Hangup() [ChannelHungup1] exten => s,1,Verbose(0, Hangup1: ${CHANNEL}) same => n,Return() [ChannelHungup2] exten => s,1,Verbose(0, Hangup2: ${CHANNEL}) same => n,Return() [BridgeHungup1] exten => s,1,Verbose(0, BridgeHungUp1: ${CHANNEL}) same => n,Return() [BridgeHungup2] exten => s,1,Verbose(0, BridgeHungUp2: ${CHANNEL}) same => n,Return() [BridgeChannels] exten => s,1,NoOp() same => n,Verbose(0, Bridge Channels: ${CHANNEL} and ${Channel1}) same => n,Bridge(${Channel1},F(bridgedEnd,s,1)) same => n,Verbose(0, Bridge Exit - BRIDGERESULT = ${BRIDGERESULT}) same => n,HangUp() exten => h,1,Goto(BridgeHungUp1,s,1) [bridgedEnd] exten => s,1,Verbose(0, Bridge End: ${CHANNEL}) same => n,HangUp() exten => h,1,Goto(BridgeHungUp2,s,1) {noformat} I then issued the following (Channel1): {noformat} *CLI> originate Local/940 extension 150 Answered: Local/940@default-00000001;1 Add hangup handler to: Local/940@default-00000001;1 {noformat} And similarly (Channel2): {noformat} *CLI> originate Local/940 extension 151 Answered: Local/940@default-00000002;1 Add hangup handler to: Local/940@default-00000002;1 {noformat} At this point there are two channels playing back demo-congrats and each have their own hangup handlers specified. I then sent a redirect via AMI, bridging the Channel2 (bridger) with Channel1 (bridgee): {noformat} Action: Redirect Channel: Local/940@default-00000002;1 Context: BridgeChannels Exten: s Priority: 1 {noformat} {noformat} Bridge Channels: Local/940@default-00000002;1 and Local/940@default-00000001;1 {noformat} Since Channel1 (bridgee) was started first it'll hangup first when Playback ends. Once it hung up here's the output I got: {noformat} Hangup1: Local/940@default-00000001;1 Bridge Exit - BRIDGERESULT = SUCCESS Hangup2: Local/940@default-00000002;1 {noformat} As you can see both channel's hang up handlers were called, so I'm missing something, or maybe something else is going on aside from a handler being dropped during a redirection? Or did you mean the BridgeEnd handler specified using the {{F}} option was not invoked vs. a channel's? By: Morten Sølvberg (Soelvberg) 2022-06-10 07:14:42.939-0500 Hi Kevin Damn it - you´re right. And I was so sure... :-) I see now that the time it takes to push a recording was causing the channels to end in a different order than before. This must naturally not happen, so after refactoring the dialplan a little, it now works as a charm every time. And in a lot safer manner. So I'm sorry to have taken your time, but thankful for your thurough answer. |