# Hangup in case of bridged channels (via AMI)

**URL:** <https://community.asterisk.org/t/hangup-in-case-of-bridged-channels-via-ami/87298>\
**Category:** Asterisk Dialplan\
**Created:** [January 26, 2021, 3:16pm UTC](https://community.asterisk.org/t/hangup-in-case-of-bridged-channels-via-ami/87298 "2021-01-26T15:16:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FischC](https://avatars.discourse-cdn.com/v4/letter/f/ee7513/32.png) [@FischC](https://community.asterisk.org/u/FischC)\
**Post date:** [January 26, 2021, 3:16pm UTC](https://community.asterisk.org/t/hangup-in-case-of-bridged-channels-via-ami/87298/1 "2021-01-26T15:16:45Z")

</div>

Hi!

When I bridge 2 channels using the **AMI action bridge** everything works fine, except that if one peer of the bridged call hangs up the dialplan is restarted for the opposite peer.

Dialplan:

```auto
exten => _30XX,1,Verbose("Here we go ...");
 same => 2,Dial(PJSIP/${EXTEN},,tTge)
 same => 3,Verbose("Here we go again ...");
 same => 4,Hangup()

```

Extension 3030 calls 3040 first and afterwards 3050, then the call is bridged using AMI action bridge (verbose output):

```auto
    -- Channel PJSIP/3040-0000002a left 'simple_bridge' basic-bridge <1b3d48b8-80a7-4b7e-99c6-f50c00a7a24b>
    -- Channel PJSIP/3050-0000002c left 'simple_bridge' basic-bridge <1b3d48b8-80a7-4b7e-99c6-f50c00a7a24b>
  == Starting PJSIP/3050-0000002c at default,,1 failed so falling back to exten 's'
    -- Channel 'PJSIP/3050-0000002c' sent to invalid extension: context,exten,priority=default,s,1
    -- Executing [i@default:1] Playback("PJSIP/3050-0000002c", "invalid") in new stack
    -- <PJSIP/3050-0000002c> Playing 'invalid.slin' (language 'en')
    -- Auto fallthrough, channel 'PJSIP/3050-0000002c' status is 'UNKNOWN'
    -- Executing [h@default:1] Verbose("PJSIP/3050-0000002c", ""Hangup!!!!"") in new stack
Hangup!!!!

```

Any hints how to supress this unexpected dialplan behaviour?

Thanks  
// FischC

---

<div class="post-metadata">

**Author:** ![rmudgett](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/rmudgett/32/1843_2.png) [@rmudgett](https://community.asterisk.org/u/rmudgett)\
**Post date:** [January 26, 2021, 11:55pm UTC](https://community.asterisk.org/t/hangup-in-case-of-bridged-channels-via-ami/87298/2 "2021-01-26T23:55:22Z")

</div>

It looks like the Dial options g and e are to blame. You are using the bridge action to interfere with the functioning of those Dial options.

---

<div class="post-metadata">

**Author:** ![FischC](https://avatars.discourse-cdn.com/v4/letter/f/ee7513/32.png) [@FischC](https://community.asterisk.org/u/FischC)\
**Post date:** [January 27, 2021, 12:55pm UTC](https://community.asterisk.org/t/hangup-in-case-of-bridged-channels-via-ami/87298/3 "2021-01-27T12:55:32Z")

</div>

Thanks for you answer,but I’ve tried without options e,g,e&g, etc. but this doesn’t make a difference.

I did some additional testing:  
\*) Bridge 2 incoming SIP calls (3040-\>3030, 3050-\>3030) - OK  
\*) Bridge 1 incoming and 1 outgoing SIP call (3040-\>3030, 3030-\>3050) - OK  
\*) Bridge 2 outgoing SIP calls (3030-\>3040, 3030-\>3050) - NOK. In this case, if the last channel has  
left the simple bridge, the dialplan ist restarted. Any clues why this is happening and/or hints how to further debug this issue?

In the meantime I’ve implemented the following (dialplan) workaround :

```auto
exten => s,1,NoOP()
 same => n,GotoIf($[${HANGUPCAUSE} = 16]?Done)
 same => n,NoOP()
 same => n(Done),Verbose("${CALLERID(num)} hung up, do not restart dialplan! ")

```

Debug:

```auto
    -- Channel PJSIP/3050-00000216 joined 'simple_bridge' basic-bridge <6ccafe5b-b991-419e-b131-2949e0481966>
    -- Channel PJSIP/3030-00000215 joined 'simple_bridge' basic-bridge <6ccafe5b-b991-419e-b131-2949e0481966>
    -- Channel PJSIP/3040-00000212 left 'simple_bridge' basic-bridge <a3bd3686-7a38-4998-a3b0-1c92d4f2ad33>
    -- Channel PJSIP/3040-00000212 joined 'simple_bridge' basic-bridge <22d83754-b36d-42c0-bc3c-3a26cb9ffe9f>
    -- Channel PJSIP/3050-00000216 left 'simple_bridge' basic-bridge <6ccafe5b-b991-419e-b131-2949e0481966>
    -- Channel PJSIP/3030-00000211 left 'simple_bridge' basic-bridge <a3bd3686-7a38-4998-a3b0-1c92d4f2ad33>
    -- Channel PJSIP/3050-00000216 joined 'simple_bridge' basic-bridge <22d83754-b36d-42c0-bc3c-3a26cb9ffe9f>
  == Spawn extension (default, 3040, 2) exited non-zero on 'PJSIP/3030-00000211'
    -- Executing [h@default:1] Verbose("PJSIP/3030-00000211", ""Hangup!!!!"") in new stack
Hangup!!!!
    -- Channel PJSIP/3030-00000215 left 'simple_bridge' basic-bridge <6ccafe5b-b991-419e-b131-2949e0481966>
  == Spawn extension (default, 3050, 2) exited non-zero on 'PJSIP/3030-00000215'
    -- Executing [h@default:1] Verbose("PJSIP/3030-00000215", ""Hangup!!!!"") in new stack
Hangup!!!!
    -- <PJSIP/3040-00000212> Playing 'beep.slin' (language 'en')
    -- <PJSIP/3050-00000216> Playing 'beep.slin' (language 'en')
    -- Channel PJSIP/3050-00000216 left 'simple_bridge' basic-bridge <22d83754-b36d-42c0-bc3c-3a26cb9ffe9f>
    -- Channel PJSIP/3040-00000212 left 'simple_bridge' basic-bridge <22d83754-b36d-42c0-bc3c-3a26cb9ffe9f>
  == Starting PJSIP/3040-00000212 at default,,1 failed so falling back to exten 's'
    -- Executing [s@default:1] NoOp("PJSIP/3040-00000212", "") in new stack
    -- Executing [s@default:2] GotoIf("PJSIP/3040-00000212", "1?Done") in new stack
    -- Goto (default,s,4)
    -- Executing [s@default:4] Verbose("PJSIP/3040-00000212", ""3040 hung up, do not restart dialplan! "") in new stack
3040 hung up, do not restart dialplan! 
    -- Auto fallthrough, channel 'PJSIP/3040-00000212' status is 'UNKNOWN'
    -- Executing [h@default:1] Verbose("PJSIP/3040-00000212", ""Hangup!!!!"") in new stack
Hangup!!!!

```

Thanks & kind regards  
// Clemens

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [February 26, 2021, 12:55pm UTC](https://community.asterisk.org/t/hangup-in-case-of-bridged-channels-via-ami/87298/4 "2021-02-26T12:55:42Z")

</div>

Closed on February 26, 2021, 12:55pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
