adhearsion / punchblock

Telephony middleware library for Ruby
adhearsion.com/punchblock
MIT License
40 stars 34 forks source link

Asterisk bridges terminate both parties when one leaves #193

Closed benlangfeld closed 10 years ago

benlangfeld commented 10 years ago

Example code:

Adhearsion.router do
  openended do
    route 'default' do
      answer
      if Adhearsion.active_calls.size > 1
        other_call = Adhearsion.active_calls.first[1]
        logger.info "We already have a call (#{other_call}). Lets join to it!"
        join other_call
      end
      logger.info "Controller terminating"
    end
  end
end

On FreeSWITCH mod_rayo (regardless of who hangs up):

[2013-12-18 14:46:18] INFO  Adhearsion::Router: Call e7f5ce8b-7052-4b96-b17f-59408dd47259 selected route "default" (#<Proc:0x007ff797386508@/Users/ben/Desktop/foo/config/adhearsion.rb:30>)
[2013-12-18 14:46:18] INFO  Adhearsion::Call: e7f5ce8b-7052-4b96-b17f-59408dd47259@freeswitch.local-dev.mojolingo.com: Executing controller #<Adhearsion::CallController call=e7f5ce8b-7052-4b96-b17f-59408dd47259, metadata={}>
[2013-12-18 14:46:18] INFO  Adhearsion::Call: e7f5ce8b-7052-4b96-b17f-59408dd47259@freeswitch.local-dev.mojolingo.com: Controller terminating
[2013-12-18 14:46:18] INFO  Adhearsion::Router::Route: Call routing completed, keeping the call alive at controller/router request.
[2013-12-18 14:46:22] INFO  Adhearsion::Router: Call fd922f64-7a7a-424c-bead-1ad234120298 selected route "default" (#<Proc:0x007ff797386508@/Users/ben/Desktop/foo/config/adhearsion.rb:30>)
[2013-12-18 14:46:22] INFO  Adhearsion::Call: fd922f64-7a7a-424c-bead-1ad234120298@freeswitch.local-dev.mojolingo.com: Executing controller #<Adhearsion::CallController call=fd922f64-7a7a-424c-bead-1ad234120298, metadata={}>
[2013-12-18 14:46:22] INFO  Adhearsion::Call: fd922f64-7a7a-424c-bead-1ad234120298@freeswitch.local-dev.mojolingo.com: We already have a call (e7f5ce8b-7052-4b96-b17f-59408dd47259). Lets join to it!
[2013-12-18 14:46:22] INFO  Adhearsion::Call: fd922f64-7a7a-424c-bead-1ad234120298@freeswitch.local-dev.mojolingo.com: Joining to e7f5ce8b-7052-4b96-b17f-59408dd47259
[2013-12-18 14:46:22] INFO  Adhearsion::Call: fd922f64-7a7a-424c-bead-1ad234120298@freeswitch.local-dev.mojolingo.com: Joined to call xmpp:e7f5ce8b-7052-4b96-b17f-59408dd47259@freeswitch.local-dev.mojolingo.com
[2013-12-18 14:46:22] INFO  Adhearsion::Call: e7f5ce8b-7052-4b96-b17f-59408dd47259@freeswitch.local-dev.mojolingo.com: Joined to call xmpp:fd922f64-7a7a-424c-bead-1ad234120298@freeswitch.local-dev.mojolingo.com
[2013-12-18 14:46:55] INFO  Adhearsion::Call: e7f5ce8b-7052-4b96-b17f-59408dd47259@freeswitch.local-dev.mojolingo.com: Unjoined from call xmpp:fd922f64-7a7a-424c-bead-1ad234120298@freeswitch.local-dev.mojolingo.com
[2013-12-18 14:46:55] INFO  Adhearsion::Call: fd922f64-7a7a-424c-bead-1ad234120298@freeswitch.local-dev.mojolingo.com: Unjoined from call xmpp:e7f5ce8b-7052-4b96-b17f-59408dd47259@freeswitch.local-dev.mojolingo.com
[2013-12-18 14:46:55] INFO  Adhearsion::Call: e7f5ce8b-7052-4b96-b17f-59408dd47259@freeswitch.local-dev.mojolingo.com: Call ended due to hungup
[2013-12-18 14:46:55] INFO  Adhearsion::Call: fd922f64-7a7a-424c-bead-1ad234120298@freeswitch.local-dev.mojolingo.com: Controller terminating
[2013-12-18 14:46:55] INFO  Adhearsion::Router::Route: Call routing completed, keeping the call alive at controller/router request.
[2013-12-18 14:47:02] INFO  Adhearsion::Call: fd922f64-7a7a-424c-bead-1ad234120298@freeswitch.local-dev.mojolingo.com: Call ended due to hungup

On Asterisk:

when call hangs up: https://gist.github.com/benlangfeld/ea9ef8a68194d7b45d01 when other_call hangs up: https://gist.github.com/benlangfeld/597662aaa5f2b3450cd6

JustinAiken commented 10 years ago

BTW, my observance of this issue was on Asterisk 11.3

benlangfeld commented 10 years ago

Turns out this only fixes the issue for inbound calls. Outbound calls still present the same problem:

Adhearsion.router do
  openended do
    route 'default' do
      answer
      logger.info "Placing outbound call"
      first_call = call
      other_call = Adhearsion::OutboundCall.originate 'SIP/usera' do
        call[:ahn_prevent_hangup] = true
        logger.info "Joining!"
        call.join first_call
      end
      logger.info "Controller terminating"
    end
  end
end