adhearsion / adhearsion

A Ruby framework for building telephony applications
http://adhearsion.com
MIT License
609 stars 127 forks source link

originating calls with ahn 2 and Adhearsion::Asterisk.execute_ami_action lead to "OutgoingSpoolFailed"-error #250

Closed fwoeck closed 11 years ago

fwoeck commented 11 years ago

Hello,

after migration from ahn version 1 to 2, the originate-strategy I used before, fails. I start a Adhearsion::Asterisk.execute_ami_action(:originate, ...) to inject a soundfile into a running ConfBridge-conference with asterisk 11. When I do this, asterisk says something like "Executing [failed@robocall:1] AGI("OutgoingSpoolFailed", "agi:async") in new stack" and a timeout occurs.

Please see https://gist.github.com/4518046 for a detailed log. The :originate happens at 14:14:38 in line 836.

Can you give me a hint here? Thanks in advance, Frank

def inject_soundfile(sound)
  Adhearsion::Asterisk.execute_ami_action(:originate, {
    channel:  "Local/#{self.id}@#{sound}",
    context:  "robocall",
      priority:  1,
      callerid:  self.id,
      timeout:   1000,
      exten:     pin
  })
  return true
end

class RobocallContext < Adhearsion::CallController

  def run
    ActiveRecord::Base.connection_pool.with_connection {
      answer
      conf = Conference.where(pin: "%04d" % call.to.to_i).first
      execute("ConfBridge", conf.room) if conf
    }
    hangup
  end
end

class ExtendableContext < Adhearsion::CallController

  def run
    ActiveRecord::Base.connection_pool.with_connection {
      answer
      conf = Conference.where(id: call.variables[:x_agi_callerid].to_i).first
      conf.inject_extension_note(self) if conf
    }
    hangup
  end
end

Adhearsion.router do
  route 'default',    DefaultContext,    agi_context: 'adhearsion'
  route 'robocall',   RobocallContext,   agi_context: 'robocall'
  route 'extendable', ExtendableContext, agi_context: 'extendable'
end

# /etc/asterisk/extensions.conf:
# 
# [adhearsion]
# switch => Realtime/@
# exten => _.,1,AGI(agi:async)
# 
# [robocall]
# exten => _.,1,AGI(agi:async)
# 
# [extendable]
# exten => _.,1,AGI(agi:async)
benlangfeld commented 11 years ago

I don't see any audio file playback here. Where is that happening?

Regards, Ben Langfeld

On 12 January 2013 08:26, Frank Wöckener notifications@github.com wrote:

Hello,

after migration from ahn version 1 to 2, the originate-strategy I used before, fails. I start a Adhearsion::Asterisk.execute_ami_action(:originate, ...) to inject a soundfile into a running ConfBridge-conference with asterisk 11. When I do this, asterisk says something like "Executing [failed@robocall:1] AGI("OutgoingSpoolFailed", "agi:async") in new stack" and a timeout occurs. Please see https://gist.github.com/4518046 for a detailed log.

Can you give me a hint here? Thanks in advance, Frank

def inject_soundfile(sound) Adhearsion::Asterisk.execute_ami_action(:originate, { channel: "Local/#{self.id}@#{sound}", context: "robocall", priority: 1, callerid: self.id, timeout: 1000, exten: pin }) return trueend class RobocallContext < Adhearsion::CallController

def run ActiveRecord::Base.connection_pool.with_connection { answer conf = Conference.where(pin: "%04d" % call.to.to_i).first execute("ConfBridge", conf.room) if conf } hangup endend class ExtendableContext < Adhearsion::CallController

def run ActiveRecord::Base.connection_pool.with_connection { answer conf = Conference.where(id: call.variables[:x_agi_callerid].to_i).first conf.inject_extension_note(self) if conf } hangup endend Adhearsion.router do route 'default', DefaultContext, agi_context: 'adhearsion' route 'robocall', RobocallContext, agi_context: 'robocall' route 'extendable', ExtendableContext, agi_context: 'extendable'end

/etc/asterisk/extensions.conf:# # [adhearsion]# switch => Realtime/@# exten => .,1,AGI(agi:async)# # [robocall]# exten => .,1,AGI(agi:async)# # [extendable]# exten => _.,1,AGI(agi:async)

— Reply to this email directly or view it on GitHubhttps://github.com/adhearsion/adhearsion/issues/250.

fwoeck commented 11 years ago

ahh sorry.. in the ExtendableContext: conf.inject_extension_note(self)

class Conference < ActiveRecord::Base
  def inject_extension_note(context)
    case self.language
    when 'de'
      context.play 'ls_20'
    else
      context.play 'ls_19'
    end
  end
benlangfeld commented 11 years ago

Are you sure line 4 of your gist should not be "extendable", rather than "robocall". It seems like there's no way to get to ExtendableContext as it stands. As for the failure itself, this is coming from Asterisk. You've gotta love how they overload the extension for reporting the type of error. Adhearsion is handling this error poorly as a result, but there's nothing Adhearsion can do to prevent it. I'd suggest you take this up with the Asterisk mailing list.

Regards, Ben Langfeld

On 12 January 2013 10:12, Frank Wöckener notifications@github.com wrote:

ahh sorry.. in the ExtendableContext: conf.inject_extension_note(self)

class Conference < ActiveRecord::Base def inject_extension_note(context) case self.language when 'de' context.play 'ls_20' else context.play 'ls_19' end end

— Reply to this email directly or view it on GitHubhttps://github.com/adhearsion/adhearsion/issues/250#issuecomment-12179300.

benlangfeld commented 11 years ago

Additionally it should be noted that the failed extension is normally only invoked in extensions.conf when using call files, not AMI Originate. I'd suggest you look into using Adhearsion::OutboundCall.originate and letting Adhearsion's built-in routing (the ability to specify a call controller to .originate) to handle this for you.

Regards, Ben Langfeld

On 12 January 2013 10:17, Ben Langfeld ben@langfeld.co.uk wrote:

Are you sure line 4 of your gist should not be "extendable", rather than "robocall". It seems like there's no way to get to ExtendableContext as it stands. As for the failure itself, this is coming from Asterisk. You've gotta love how they overload the extension for reporting the type of error. Adhearsion is handling this error poorly as a result, but there's nothing Adhearsion can do to prevent it. I'd suggest you take this up with the Asterisk mailing list.

Regards, Ben Langfeld

On 12 January 2013 10:12, Frank Wöckener notifications@github.com wrote:

ahh sorry.. in the ExtendableContext: conf.inject_extension_note(self)

class Conference < ActiveRecord::Base def inject_extension_note(context) case self.language when 'de' context.play 'ls_20' else context.play 'ls_19' end end

— Reply to this email directly or view it on GitHubhttps://github.com/adhearsion/adhearsion/issues/250#issuecomment-12179300.

fwoeck commented 11 years ago

the

channel:  "Local/#{self.id}@#{sound}",

expands to

channel:  "Local/127@extendable",

so the connection is drawn this way. Concerning your last comment: is it possible to originate a call with "Adhearsion::OutboundCall.originate" so that one side goes to the extendable-extension and the oter side goes to the robocall-extension? Best, fw

fwoeck commented 11 years ago

you probably mean this, right?

class InboundCall < Adhearsion::CallController
  def run
    answer
    say "Thank you for calling, we will notify Jason that you called."
    hangup

    Adhearsion::OutboundCall.originate 'sip:jason@adhearsion.com', from: 'sip:foo@bar.com' do
      answer
      say "Foo called!"
      hangup
    end
  end
end

I'll try that!