I''m trying to access the AMI Event OriginateResponse
in my ami_logic file I have
def originate_response
puts ''---------------------''
puts "OriginateResponse #{params.inspect}"
end
but it''s not getting fired when it receives an OriginateResponse
response.
Any ideas why? Other obscure events like JabberEvent works when defined as
jabber_event, I can''t figure out why OriginateResponse has problems.
OriginateResponse is an AMI Event triggered by an AMI originate with async
set to true
Any help would be greatly apperciated.
--matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/telegraph-users/attachments/20080524/81442f5b/attachment.html>
Hello Matthew, can you see if the OriginateResponse event it arriving at your machine by using e.g. ngrep: ngrep -d any host <asterisk-ip> -W byline I once recognized that it is important to precisely look at the event which is coming from the asterisk in terms on upcase/lowercase letters You may also put a puts or p line into ami_server.rb in the watch_for_events method to see if the event is arriving or not e.g. while events = @client.get_next_events for event in events p event . . . Best regards Peter Matthew Fong schrieb:> I''m trying to access the AMI Event OriginateResponse > > in my ami_logic file I have > > def originate_response > puts ''---------------------'' > puts "OriginateResponse #{params.inspect}" > end > > but it''s not getting fired when it receives an OriginateResponse > response. Any ideas why? Other obscure events like JabberEvent works > when defined as jabber_event, I can''t figure out why OriginateResponse > has problems. > > OriginateResponse is an AMI Event triggered by an AMI originate with > async set to true > > Any help would be greatly apperciated. > > --matt > ------------------------------------------------------------------------ > > _______________________________________________ > Telegraph-users mailing list > Telegraph-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/telegraph-users >
Hi Peter,
Thanks for the response and help. Asterisks IS sending the OriginateResponse
packet, but for whatever reason it never makes it into the while events
loop. I confirmed that the OriginateResponse event is being sent both by
ngrep and by manually opening a client connection with asterisks and
mimicking a server with a telnet prompt.
the p event never gets fired for the OriginateResponse, so it must be
something preventing it from getting to that line of code. The
OriginateResponse event contains an ActionID, which I might guess might
cause ami_event_handler to treat it as if it were a response from an action,
rather than a typical event. could this be a possible cause? Any suggestions
on how to fix it?
Again any help would be appreciated.
--matt
ami_event_server output
---------------------
cdr {:destination_channel=>"",
:destination_context=>"default",
:last_application=>"", :duration=>"0",
:last_data=>"", :answer_time=>"",
:channel=>"**Unknown**", :billable_seconds=>"0",
:privilege=>"call,all",
:ama_flags=>"DOCUMENTATION", :disposition=>"FAILED",
:user_field=>"",
:account_code=>"", :destination=>"s",
:event=>"Cdr", :caller_id=>"",
:source=>"", :start_time=>"2008-05-27 14:37:33",
:end_time=>"2008-05-27
14:37:33", :unique_id=>"1211913453.1"}
{:destination_channel=>"",
:destination_context=>"default",
:last_application=>"", :duration=>"0",
:last_data=>"", :answer_time=>"",
:channel=>"**Unknown**", :billable_seconds=>"0",
:privilege=>"call,all",
:ama_flags=>"DOCUMENTATION", :disposition=>"FAILED",
:user_field=>"",
:account_code=>"", :destination=>"s",
:event=>"Cdr", :caller_id=>"",
:source=>"", :start_time=>"2008-05-27 14:38:30",
:end_time=>"2008-05-27
14:38:30", :unique_id=>"1211913510.2"}
---------------------
cdr {:destination_channel=>"",
:destination_context=>"default",
:last_application=>"", :duration=>"0",
:last_data=>"", :answer_time=>"",
:channel=>"**Unknown**", :billable_seconds=>"0",
:privilege=>"call,all",
:ama_flags=>"DOCUMENTATION", :disposition=>"FAILED",
:user_field=>"",
:account_code=>"", :destination=>"s",
:event=>"Cdr", :caller_id=>"",
:source=>"", :start_time=>"2008-05-27 14:38:30",
:end_time=>"2008-05-27
14:38:30", :unique_id=>"1211913510.2"}
ngrep output
------------------------------------------------------------------------------------------------
##
T 127.0.0.1:40976 -> 127.0.0.1:9000 [AP]
......0......".do_action......i....Y..{.:.action:.originate:.priority".1:.channe
l".SIP/sr6:
exteni.:
asyncT:.context".default......0
##
T 127.0.0.1:49436 -> 127.0.0.1:5038 [AP]
Action: originate.
##
T 127.0.0.1:49436 -> 127.0.0.1:5038 [AP]
actionid: 1211913510.22177.
channel: SIP/sr6.
priority: 1.
context: default.
async: true.
exten: 1.
.
##
T 127.0.0.1:5038 -> 127.0.0.1:49436 [AP]
Response: Success.
##
T 127.0.0.1:5038 -> 127.0.0.1:49436 [AP]
ActionID: 1211913510.22177.
##
T 127.0.0.1:5038 -> 127.0.0.1:49436 [AP]
Message: Originate successfully queued.
.
##
T 127.0.0.1:5038 -> 127.0.0.1:49436 [AP]
Event: Cdr.
Privilege: call,all.
AccountCode: .
Source: .
Destination: s.
DestinationContext: default.
CallerID: .
Channel: **Unknown**.
DestinationChannel: .
LastApplication: .
LastData: .
StartTime: 2008-05-27 14:38:30.
AnswerTime: .
EndTime: 2008-05-27 14:38:30.
Duration: 0.
BillableSeconds: 0.
Disposition: FAILED.
AMAFlags: DOCUMENTATION.
UniqueID: 1211913510.2.
UserField: .
.
##
T 127.0.0.1:5038 -> 127.0.0.1:49436 [AP]
Event: OriginateResponse.
Privilege: call,all.
ActionID: 1211913510.22177.
Response: Failure.
Channel: SIP/sr6.
Context: default.
Exten: 1.
Reason: 0.
Uniqueid: <null>.
CallerID: <unknown>.
CallerIDNum: <unknown>.
CallerIDName: <unknown>.
.
##
T 127.0.0.1:9000 -> 127.0.0.1:40976 [AP]
......T......o: Telegraph::AsteriskResponse.:. at results[.:. at
message""Originate
su ccessfully queued:. at attributes
{.:. at successF:. at completeT:. at action_idf.1211913510.
22177.1{:. at events[.
#
T 127.0.0.1:9000 -> 127.0.0.1:40975 [AP]
......T......[.{.:.last_data".:.ama_flags".DOCUMENTATION:.channel".**Unknown**:.
destination".s:.start_time".2008-05-27
14:38:30:.unique_id".1211913510.2:.destin
ation_context".default:.answer_time".:.privilege".call,all:.user_field".:.caller
_id".:.end_time".2008-05-27
14:38:30:.disposition".FAILED:.destination_channel".
:.duration".0:.source".:.last_application".:
event".Cdr:.billable_seconds".0:.account_code".
##
T 127.0.0.1:40975 -> 127.0.0.1:9000 [AP]
......0......".get_next_events......i.......0
On Mon, May 26, 2008 at 5:45 AM, Peter P GMX <Prometheus001 at gmx.net>
wrote:
> Hello Matthew,
>
> can you see if the OriginateResponse event it arriving at your machine by
> using e.g. ngrep:
>
> ngrep -d any host <asterisk-ip> -W byline
>
> I once recognized that it is important to precisely look at the event which
> is coming from the asterisk in terms on upcase/lowercase letters
>
> You may also put a puts or p line into ami_server.rb in the
> watch_for_events method to see if the event is arriving or not
> e.g.
> while events = @client.get_next_events
> for event in events
> p event
> .
> .
> .
>
> Best regards
> Peter
>
> Matthew Fong schrieb:
>
>> I''m trying to access the AMI Event OriginateResponse
>>
>> in my ami_logic file I have
>>
>> def originate_response
>> puts ''---------------------''
>> puts "OriginateResponse #{params.inspect}"
>> end
>>
>> but it''s not getting fired when it receives an
OriginateResponse response.
>> Any ideas why? Other obscure events like JabberEvent works when defined
as
>> jabber_event, I can''t figure out why OriginateResponse has
problems.
>>
>> OriginateResponse is an AMI Event triggered by an AMI originate with
async
>> set to true
>>
>> Any help would be greatly apperciated.
>>
>> --matt
>>
------------------------------------------------------------------------
>>
>> _______________________________________________
>> Telegraph-users mailing list
>> Telegraph-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/telegraph-users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/telegraph-users/attachments/20080527/e1dd960d/attachment.html>
Just a quick idea:
The OriginateResponse contains both an event and a response property.
Maybe this is the reason it is handled differently inside Telegraph.
The event cache is filled in ami_server.rb around line 650-690.
#we have a response...
if line =~ /^Event:\s(.*)#{CRLF}/
complete = false
action_id=nil
event = Hash.new
event[:event] = $1
while line=read_line do
if event[:event].downcase =~ /complete/
complete = true
end
if line =~ /^(\w+):\s(.*)#{CRLF}/
if $1=="ActionID"
action_id= $2
else
event[underscorize($1).to_sym] = $2
end
elsif line == CRLF
if action_id
@response_cache.synchronize do
response = @response_cache.detect{|r|
r.action_id.to_s == action_id.to_s}
if response
response.events << event
response.complete = complete
end
@response_cache_pending.signal if response
&& response.complete
end
else
@event_cache.synchronize do
@event_cache << event
@event_cache_pending.signal
end
end
break
end
end
Right now I cannot test on a working system. Maybe you can add some
print statements and figure out where the request is overrun and give me
a feedback?
Best regards
Peter
Matthew Fong schrieb:> Hi Peter,
>
> Thanks for the response and help. Asterisks IS sending the
> OriginateResponse packet, but for whatever reason it never makes it
> into the while events loop. I confirmed that the OriginateResponse
> event is being sent both by ngrep and by manually opening a client
> connection with asterisks and mimicking a server with a telnet prompt.
>
> the p event never gets fired for the OriginateResponse, so it must be
> something preventing it from getting to that line of code. The
> OriginateResponse event contains an ActionID, which I might guess
> might cause ami_event_handler to treat it as if it were a response
> from an action, rather than a typical event. could this be a possible
> cause? Any suggestions on how to fix it?
>
> Again any help would be appreciated.
>
> --matt
>
>
> ami_event_server output
> ---------------------
> cdr {:destination_channel=>"",
:destination_context=>"default",
> :last_application=>"", :duration=>"0",
:last_data=>"",
> :answer_time=>"", :channel=>"**Unknown**",
:billable_seconds=>"0",
> :privilege=>"call,all",
:ama_flags=>"DOCUMENTATION",
> :disposition=>"FAILED", :user_field=>"",
:account_code=>"",
> :destination=>"s", :event=>"Cdr",
:caller_id=>"", :source=>"",
> :start_time=>"2008-05-27 14:37:33",
:end_time=>"2008-05-27 14:37:33",
> :unique_id=>"1211913453.1"}
> {:destination_channel=>"",
:destination_context=>"default",
> :last_application=>"", :duration=>"0",
:last_data=>"",
> :answer_time=>"", :channel=>"**Unknown**",
:billable_seconds=>"0",
> :privilege=>"call,all",
:ama_flags=>"DOCUMENTATION",
> :disposition=>"FAILED", :user_field=>"",
:account_code=>"",
> :destination=>"s", :event=>"Cdr",
:caller_id=>"", :source=>"",
> :start_time=>"2008-05-27 14:38:30",
:end_time=>"2008-05-27 14:38:30",
> :unique_id=>"1211913510.2"}
>
> ---------------------
> cdr {:destination_channel=>"",
:destination_context=>"default",
> :last_application=>"", :duration=>"0",
:last_data=>"",
> :answer_time=>"", :channel=>"**Unknown**",
:billable_seconds=>"0",
> :privilege=>"call,all",
:ama_flags=>"DOCUMENTATION",
> :disposition=>"FAILED", :user_field=>"",
:account_code=>"",
> :destination=>"s", :event=>"Cdr",
:caller_id=>"", :source=>"",
> :start_time=>"2008-05-27 14:38:30",
:end_time=>"2008-05-27 14:38:30",
> :unique_id=>"1211913510.2"}
>
>
>
>
>
>
>
> ngrep output
>
------------------------------------------------------------------------------------------------
>
> ##
> T 127.0.0.1:40976 <http://127.0.0.1:40976> -> 127.0.0.1:9000
> <http://127.0.0.1:9000> [AP]
>
......0......".do_action......i....Y..{.:.action:.originate:.priority".1:.channe
> l".SIP/sr6:
> exteni.:
> asyncT:.context".default......0
> ##
> T 127.0.0.1:49436 <http://127.0.0.1:49436> -> 127.0.0.1:5038
> <http://127.0.0.1:5038> [AP]
> Action: originate.
>
> ##
> T 127.0.0.1:49436 <http://127.0.0.1:49436> -> 127.0.0.1:5038
> <http://127.0.0.1:5038> [AP]
> actionid: 1211913510.22177.
> channel: SIP/sr6.
> priority: 1.
> context: default.
> async: true.
> exten: 1.
> .
>
> ##
> T 127.0.0.1:5038 <http://127.0.0.1:5038> -> 127.0.0.1:49436
> <http://127.0.0.1:49436> [AP]
> Response: Success.
>
> ##
> T 127.0.0.1:5038 <http://127.0.0.1:5038> -> 127.0.0.1:49436
> <http://127.0.0.1:49436> [AP]
> ActionID: 1211913510.22177.
>
> ##
> T 127.0.0.1:5038 <http://127.0.0.1:5038> -> 127.0.0.1:49436
> <http://127.0.0.1:49436> [AP]
> Message: Originate successfully queued.
> .
>
> ##
> T 127.0.0.1:5038 <http://127.0.0.1:5038> -> 127.0.0.1:49436
> <http://127.0.0.1:49436> [AP]
> Event: Cdr.
> Privilege: call,all.
> AccountCode: .
> Source: .
> Destination: s.
> DestinationContext: default.
> CallerID: .
> Channel: **Unknown**.
> DestinationChannel: .
> LastApplication: .
> LastData: .
> StartTime: 2008-05-27 14:38:30.
> AnswerTime: .
> EndTime: 2008-05-27 14:38:30.
> Duration: 0.
> BillableSeconds: 0.
> Disposition: FAILED.
> AMAFlags: DOCUMENTATION.
> UniqueID: 1211913510.2.
> UserField: .
> .
>
> ##
> T 127.0.0.1:5038 <http://127.0.0.1:5038> -> 127.0.0.1:49436
> <http://127.0.0.1:49436> [AP]
> Event: OriginateResponse.
> Privilege: call,all.
> ActionID: 1211913510.22177.
> Response: Failure.
> Channel: SIP/sr6.
> Context: default.
> Exten: 1.
> Reason: 0.
> Uniqueid: <null>.
> CallerID: <unknown>.
> CallerIDNum: <unknown>.
> CallerIDName: <unknown>.
> .
>
> ##
> T 127.0.0.1:9000 <http://127.0.0.1:9000> -> 127.0.0.1:40976
> <http://127.0.0.1:40976> [AP]
> ......T......o:
> Telegraph::AsteriskResponse.:. at results[.:. at
message""Originate
> su ccessfully
> queued:. at attributes{.:. at successF:. at completeT:. at
action_idf.1211913510.
> 22177.1{:. at events[.
> #
> T 127.0.0.1:9000 <http://127.0.0.1:9000> -> 127.0.0.1:40975
> <http://127.0.0.1:40975> [AP]
>
......T......[.{.:.last_data".:.ama_flags".DOCUMENTATION:.channel".**Unknown**:.
> destination".s:.start_time".2008-05-27
> 14:38:30:.unique_id".1211913510.2:.destin
>
ation_context".default:.answer_time".:.privilege".call,all:.user_field".:.caller
> _id".:.end_time".2008-05-27
> 14:38:30:.disposition".FAILED:.destination_channel".
> :.duration".0:.source".:.last_application".:
> event".Cdr:.billable_seconds".0:.account_code".
> ##
> T 127.0.0.1:40975 <http://127.0.0.1:40975> -> 127.0.0.1:9000
> <http://127.0.0.1:9000> [AP]
> ......0......".get_next_events......i.......0
>
>
> On Mon, May 26, 2008 at 5:45 AM, Peter P GMX <Prometheus001 at gmx.net
> <mailto:Prometheus001 at gmx.net>> wrote:
>
> Hello Matthew,
>
> can you see if the OriginateResponse event it arriving at your
> machine by using e.g. ngrep:
>
> ngrep -d any host <asterisk-ip> -W byline
>
> I once recognized that it is important to precisely look at the
> event which is coming from the asterisk in terms on
> upcase/lowercase letters
>
> You may also put a puts or p line into ami_server.rb in the
> watch_for_events method to see if the event is arriving or not
> e.g.
> while events = @client.get_next_events
> for event in events
> p event
> .
> .
> .
>
> Best regards
> Peter
>
> Matthew Fong schrieb:
>
> I''m trying to access the AMI Event OriginateResponse
>
> in my ami_logic file I have
>
> def originate_response
> puts ''---------------------''
> puts "OriginateResponse #{params.inspect}"
> end
>
> but it''s not getting fired when it receives an
> OriginateResponse response. Any ideas why? Other obscure
> events like JabberEvent works when defined as jabber_event, I
> can''t figure out why OriginateResponse has problems.
>
> OriginateResponse is an AMI Event triggered by an AMI
> originate with async set to true
>
> Any help would be greatly apperciated.
>
> --matt
>
------------------------------------------------------------------------
>
> _______________________________________________
> Telegraph-users mailing list
> Telegraph-users at rubyforge.org
> <mailto:Telegraph-users at rubyforge.org>
> http://rubyforge.org/mailman/listinfo/telegraph-users
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Telegraph-users mailing list
> Telegraph-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/telegraph-users
>