Christian Moeller
2007-Jul-15 19:10 UTC
[Telegraph-users] redirect_to enters infinite loop
Hey,
I''m basically trying to run an example as explained in the Telegraph
wiki. I
want to do a redirect like this:
class MyControllerController < ApplicationController
def index
render_voice do |voice|
voice.redirect_to :action => ''welcome''
end
end
def welcome
render_voice do |voice|
voice.play "hello-world"
end
end
end
The result is an infinate loop that goes on even after I hang up the call.
The agi_server gives the following (repetetive) output:
Processing MyControllerController#index (for 0.0.0.0 at 2007-07-15 20:39:09)
[POST]
[2007-07-15 20:39:09] INFO Session ID: e5fb1b0cd29c80eb6b8fce3ef9e60ba0
[2007-07-15 20:39:09] INFO Parameters:
{"agi_enhanced"=>"0.0",
"agi_callington"=>"0",
"agi_network"=>"yes",
"agi_accountcode"=>nil,
"agi_callingani2"=>"0",
"agi_request"=>"agi://127.0.0.1/my_controller/index",
"agi_callingpres"=>"0",
"agi_calleridname"=>"John",
"agi_callerid"=>"john",
"agi_language"=>"en",
"agi_network_script"=>"my_controller/index",
"agi_extension"=>"123",
"agi_priority"=>"1",
"agi_type"=>"SIP",
"action"=>"index",
"agi_dnid"=>"123",
"agi_callingtns"=>"0",
"controller"=>"my_controller",
"agi_channel"=>"SIP/john-08204748",
"agi_context"=>"internal",
"agi_uniqueid"=>" 1184524744.7",
"agi_rdnis"=>"unknown"}
[2007-07-15 20:39:09] INFO Completed in 0.00010 (10000 reqs/sec) | [
http://agi/]
[2007-07-15 20:39:09] INFO
I call the script from Asterisk like this in extensions.conf:
exten => 123,1,AGI(agi://127.0.0.1/my_controller/index)
I can of course not use the Rails redirect_to function since it will
redirect to a content-type of HTML and not Voice :-)
Any ideas?
Best regards,
Christian Moeller.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/telegraph-users/attachments/20070715/f9df902b/attachment.html
> > end > > The result is an infinate loop that goes on even after I hang up the call. > The agi_server gives the following (repetetive) output:I had the same problem. Clearly there is a bug but I haven''t had time to look at it at all.
Hangup detection is basically non-existent right now. I have a patch that fixes that. Unfortunately, I haven''t heard anything from Jonathan. Jonathan, if you don''t have time to work on Telegraph, can you give one of us access? I have a bunch of small fixes that I would like to commit. I''m getting ready to deploy a telegraph app to production and either need access to fix the bugs or I need to fork the source. Mike On Jul 15, 2007, at 8:26 PM, Tim Uckun wrote:>> >> end >> >> The result is an infinate loop that goes on even after I hang up >> the call. >> The agi_server gives the following (repetetive) output: > > > I had the same problem. Clearly there is a bug but I haven''t had time > to look at it at all. > _______________________________________________ > Telegraph-users mailing list > Telegraph-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/telegraph-users-- Mike Mangino http://www.elevatedrails.com
> > Jonathan, if you don''t have time to work on Telegraph, can you give > one of us access? I have a bunch of small fixes that I would like to > commit. I''m getting ready to deploy a telegraph app to production and > either need access to fix the bugs or I need to fork the source.Both Mike Vincent and I have write access and we have both modified trunk. Perhaps this was a bad idea in that we may have broken existing code. I propose integrate your patches, do some testing and a minor bugfix release and then keep trunk stable from that point on. We should have pulled a branch from the get go.
I agree with this strategy - almost :). Let''s get all the patches that everyone has in in the next week. I''m going to be updating the telegraph code in our main project in a few days so that will give a good bases for testing and then we''ll branch that into a 0.1 release branch. I suggest we keep the release branch stable and use the trunk as a true working trunk branch. It would be very good if someone can take the lead on writing test code. The first step integrating and establishing a mock system. Is anyone interested in heading that? Thanks everyone for all the contributions! JP On 7/15/07, Tim Uckun <timuckun at gmail.com> wrote:> > > > > Jonathan, if you don''t have time to work on Telegraph, can you give > > one of us access? I have a bunch of small fixes that I would like to > > commit. I''m getting ready to deploy a telegraph app to production and > > either need access to fix the bugs or I need to fork the source. > > Both Mike Vincent and I have write access and we have both modified > trunk. Perhaps this was a bad idea in that we may have broken existing > code. > > I propose integrate your patches, do some testing and a minor bugfix > release and then keep trunk stable from that point on. We should have > pulled a branch from the get go. > _______________________________________________ > Telegraph-users mailing list > Telegraph-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/telegraph-users >-- Jonathan Palley | Idapted Inc. jpalley at idapted.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/telegraph-users/attachments/20070715/daab0d87/attachment-0001.html
I committed my changes for hangup detection as well as a fix for this bug. Can you update to the latest version and try it again? Mike On Jul 15, 2007, at 2:10 PM, Christian Moeller wrote:> Hey, > > I''m basically trying to run an example as explained in the > Telegraph wiki. I want to do a redirect like this: > > class MyControllerController < ApplicationController > > def index > render_voice do |voice| > voice.redirect_to :action => ''welcome'' > end > end > > def welcome > render_voice do |voice| > voice.play "hello-world" > end > end > > end > > The result is an infinate loop that goes on even after I hang up > the call. The agi_server gives the following (repetetive) output: > > Processing MyControllerController#index (for 0.0.0.0 at 2007-07-15 > 20:39:09) [POST] > [2007-07-15 20:39:09] INFO Session ID: > e5fb1b0cd29c80eb6b8fce3ef9e60ba > 0 > [2007-07-15 20:39:09] INFO Parameters: {"agi_enhanced"=>"0.0", > "agi_callington"=>"0", "agi_network"=>"yes", > "agi_accountcode"=>nil, "agi_callingani2"=>"0", > "agi_request"=>"agi://127.0.0.1/my_controller/index", > "agi_callingpres"=>"0", "agi_calleridname"=>"John", > "agi_callerid"=>"john", "agi_language"=>"en", > "agi_network_script"=>"my_controller/index", > "agi_extension"=>"123", "agi_priority"=>"1", "agi_type"=>"SIP", > "action"=>"index", "agi_dnid"=>"123", "agi_callingtns"=>"0", > "controller"=>"my_controller", "agi_channel"=>"SIP/john-08204748", > "agi_context"=>"internal", "agi_uniqueid"=>" 1184524744.7", > "agi_rdnis"=>"unknown"} > [2007-07-15 20:39:09] INFO Completed in 0.00010 (10000 reqs/sec) > | [ http://agi/] > [2007-07-15 20:39:09] INFO > > I call the script from Asterisk like this in extensions.conf: > > exten => 123,1,AGI(agi://127.0.0.1/my_controller/index) > > I can of course not use the Rails redirect_to function since it > will redirect to a content-type of HTML and not Voice :-) > > Any ideas? > > > Best regards, > > Christian Moeller. > _______________________________________________ > Telegraph-users mailing list > Telegraph-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/telegraph-users-- Mike Mangino http://www.elevatedrails.com
Does anyone object to using rspec for tests? We''re using it with great success at ElevatedRails. If that''s okay, expect some cleanup/reorganization patches to start coming in to make things easier to test. Mike On Jul 15, 2007, at 10:02 PM, Jonathan Palley wrote:> I agree with this strategy - almost :). > Let''s get all the patches that everyone has in in the next week. > I''m going to be updating the telegraph code in our main project in > a few days so that will give a good bases for testing and then > we''ll branch that into a 0.1 release branch. I suggest we keep the > release branch stable and use the trunk as a true working trunk > branch. > > It would be very good if someone can take the lead on writing > test code. The first step integrating and establishing a mock > system. Is anyone interested in heading that? > > Thanks everyone for all the contributions! > > JP > > On 7/15/07, Tim Uckun <timuckun at gmail.com> wrote: > > > Jonathan, if you don''t have time to work on Telegraph, can you give > > one of us access? I have a bunch of small fixes that I would like to > > commit. I''m getting ready to deploy a telegraph app to production > and > > either need access to fix the bugs or I need to fork the source. > > Both Mike Vincent and I have write access and we have both modified > trunk. Perhaps this was a bad idea in that we may have broken existing > code. > > I propose integrate your patches, do some testing and a minor bugfix > release and then keep trunk stable from that point on. We should have > pulled a branch from the get go. > _______________________________________________ > Telegraph-users mailing list > Telegraph-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/telegraph-users > > > > -- > Jonathan Palley | Idapted Inc. > jpalley at idapted.com-- Mike Mangino http://www.elevatedrails.com
On 7/17/07, Mike Mangino <mmangino at elevatedrails.com> wrote:> Does anyone object to using rspec for tests? We''re using it with > great success at ElevatedRails. > > If that''s okay, expect some cleanup/reorganization patches to start > coming in to make things easier to test.None at all. That would be great.
On 7/17/07, Mike Mangino <mmangino at elevatedrails.com> wrote:> I committed my changes for hangup detection as well as a fix for this > bug. Can you update to the latest version and try it again?Good News: The infinite loop is fixed Bad News: 1) The code that Mike V wrote to properly pass parameters to controllers is gone. This means when the AGI call is made like agi://my.server.bcom/controller/action/8 the id is not set to eight. 2) once the link_to is called the application throws up a hang up error Telegraph::ChannelHungup (Telegraph::ChannelHungup): at least in my application. Here is the code. --------- prompts/record.voice ----------------------------- voice.play @prs_prompts[:recording_instructions] logger.info "recording " + @temp_file_name r = voice.record_file(@temp_file_name , 120, true, 100 ) logger.info "recorded " + r.to_yaml voice.redirect_to :action=>''accept_menu'' --------------------- ---------------prompts/accept_menu.voice------------------ logger.info "linking to dtmf" voice.link_to_dtmf @prs_prompts[:approve_recording] do link 1, :action => ''approve_recording'' link 2, :action => ''playback'' link 3, :action => ''re_record'' #try again. end --------------------------- The logger logs the "linking to dtmf" and then immediately throws up the hungup error. Perhaps there is something wrong with link_to_dtmf.
On Jul 16, 2007, at 7:07 PM, Tim Uckun wrote:> On 7/17/07, Mike Mangino <mmangino at elevatedrails.com> wrote: >> I committed my changes for hangup detection as well as a fix for this >> bug. Can you update to the latest version and try it again? > > > Good News: > > The infinite loop is fixed > > Bad News: > > 1) The code that Mike V wrote to properly pass parameters to > controllers is gone. This means when the AGI call is made like > agi://my.server.bcom/controller/action/8 the id is not set to eight.I''ll start here with the tests.> > 2) once the link_to is called the application throws up a hang up > error Telegraph::ChannelHungup (Telegraph::ChannelHungup): at least in > my application. Here is the code. >Ugh, Let me look at this. We use link_to as well with no problem. The ChannelHungup is raised when an AGI call returns -1. That also happens when a sound file isn''t found. It it possible this is the case for you? I will add a little debugging tomorrow. If I do that, can you send me traces to try to figure out what is going wrong? Mike> > --------- prompts/record.voice ----------------------------- > > voice.play @prs_prompts[:recording_instructions] > logger.info "recording " + @temp_file_name > r = voice.record_file(@temp_file_name , 120, true, 100 ) > logger.info "recorded " + r.to_yaml > > voice.redirect_to :action=>''accept_menu'' > > --------------------- > > > ---------------prompts/accept_menu.voice------------------ > > logger.info "linking to dtmf" > voice.link_to_dtmf @prs_prompts[:approve_recording] do > link 1, :action => ''approve_recording'' > link 2, :action => ''playback'' > link 3, :action => ''re_record'' #try again. > end > --------------------------- > > > The logger logs the "linking to dtmf" and then immediately throws up > the hungup error. Perhaps there is something wrong with link_to_dtmf.-- Mike Mangino http://www.elevatedrails.com
> > Ugh, Let me look at this. We use link_to as well with no problem. The > ChannelHungup is raised when an AGI call returns -1. That also > happens when a sound file isn''t found. It it possible this is the > case for you? I will add a little debugging tomorrow. If I do that, > can you send me traces to try to figure out what is going wrong?If a file is not found then it should return a zero. Here is an old snippet I have log_debug "playing #{prompt}" msg = "STREAM FILE #{prompt} #{digits} #{sample_offset}" send_to_asterisk(msg) results = get_multivalue_result log_debug results.to_yaml # Parse the return values. This is from the asterisk documentation: # # failure: 200 result=-1 endpos=<sample offset> # failure on open: 200 result=0 endpos=0 # success: 200 result=0 endpos=<offset> # digit pressed: 200 result=<digit> endpos=<offset> key_code = results["result"].to_i final_offset = results["endpos"].to_i if -1 == key_code log_debug "User Hung Up" raise UserHungUpError, "User hung up during streaming of file #{filename}" elsif 0 == key_code && 0 == final_offset log_debug "File not Found" raise SoundFileNotFoundError, "Unable to stream file #{filename} perhaps file does exist" elsif 0 == key_code log_debug "User didn''t press a key #{key_code.chr} Final Offset #{final_offset}" else log_debug "User pressed Key #{key_code.chr} Final Offset #{final_offset}" key = key_code.chr #, final_offset end