Hello list, Does anyone know if ruby-ldap supports connection timeouts? We have LDAP integrated into our authentication system to provide LDAP authentication as well. It works fine if you input a valid host/port and if the LDAP server is responding ok. However, if the host doesn''t respond for some reason (could be an invalid IP), ruby-ldap hangs there waiting forever, hanging the application, something that obvisouly could cause potential problems (since it uses passenger). Any ideas on how to handle that? Thanks, Marcelo. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Marcelo,
If that ldap lib doesn''t include any timeout settings/params for
timing out long-running ldap calls (which if you''re talking about ruby-
net-ldap, it doesn''t at this time), then one way would be to wrap
those potentially-long-running calls in ruby''s timeout (http://ruby-
doc.org/core/classes/Timeout.html) to at least force a timeout on your
app''s side of the process, something like:
...
TIMEOUT_SECS = 10 # or whatever the max should be.
...
timeout_status = nil
begin
timeout_status = Timeout::timeout(TIMEOUT_SECS) do
# do stuff that might take too long ....
end
rescue Timeout::Error => te
# log it and ...
end
...
Jeff
On Apr 1, 11:18 am, Marcelo de Moraes Serpa
<celose...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hello list,
>
> Does anyone know if ruby-ldap supports connection timeouts? We have LDAP
> integrated into our authentication system to provide LDAP authentication as
> well. It works fine if you input a valid host/port and if the LDAP server
is
> responding ok. However, if the host doesn''t respond for some
reason (could
> be an invalid IP), ruby-ldap hangs there waiting forever, hanging the
> application, something that obvisouly could cause potential problems (since
> it uses passenger).
>
> Any ideas on how to handle that?
>
> Thanks,
>
> Marcelo.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Jeff, Thanks! Every single day I''m amazed by what''s possible with Ruby, the more I learn, the less I know, but I guess that''s good :) This led me to the SystemTimer gem. The Timeout class was failing, I guess because it is external call that "cross the barriers", as explained here: http://ph7spot.com/musings/system-timer). SystemTimer works like a charm ;) Cheers, Marcelo. On Thu, Apr 1, 2010 at 1:21 PM, Jeff Lewis <jeff.burly-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Marcelo, > > If that ldap lib doesn''t include any timeout settings/params for > timing out long-running ldap calls (which if you''re talking about ruby- > net-ldap, it doesn''t at this time), then one way would be to wrap > those potentially-long-running calls in ruby''s timeout (http://ruby- > doc.org/core/classes/Timeout.html) to at least force a timeout on your > app''s side of the process, something like: > > ... > TIMEOUT_SECS = 10 # or whatever the max should be. > > ... > timeout_status = nil > begin > timeout_status = Timeout::timeout(TIMEOUT_SECS) do > # do stuff that might take too long .... > end > rescue Timeout::Error => te > # log it and ... > end > ... > > Jeff > > > On Apr 1, 11:18 am, Marcelo de Moraes Serpa <celose...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Hello list, > > > > Does anyone know if ruby-ldap supports connection timeouts? We have LDAP > > integrated into our authentication system to provide LDAP authentication > as > > well. It works fine if you input a valid host/port and if the LDAP server > is > > responding ok. However, if the host doesn''t respond for some reason > (could > > be an invalid IP), ruby-ldap hangs there waiting forever, hanging the > > application, something that obvisouly could cause potential problems > (since > > it uses passenger). > > > > Any ideas on how to handle that? > > > > Thanks, > > > > Marcelo. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Correction. SystemTimer works when binding, but *does not work* with the search / search2 method(s). If the LDAP server hangs for any reason, SystemTimer fails to kill the thread, and even though the Timeout::Error exception is thrown, it is only after much more time than what you define in the timeout_after(time) method. I''ve tried to contact Philippe, the author regarding this, let''s see how it goes. Meanwhile, if anyone has a clue on why it is failing, please share! Cheers, Marcelo. On Thu, Apr 1, 2010 at 4:09 PM, Marcelo de Moraes Serpa <celoserpa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Jeff, > > Thanks! Every single day I''m amazed by what''s possible with Ruby, the more > I learn, the less I know, but I guess that''s good :) > > This led me to the SystemTimer gem. The Timeout class was failing, I guess > because it is external call that "cross the barriers", as explained here: > http://ph7spot.com/musings/system-timer). SystemTimer works like a charm > ;) > > Cheers, > > Marcelo. > > > On Thu, Apr 1, 2010 at 1:21 PM, Jeff Lewis <jeff.burly-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hi Marcelo, >> >> If that ldap lib doesn''t include any timeout settings/params for >> timing out long-running ldap calls (which if you''re talking about ruby- >> net-ldap, it doesn''t at this time), then one way would be to wrap >> those potentially-long-running calls in ruby''s timeout (http://ruby- >> doc.org/core/classes/Timeout.html) to at least force a timeout on your >> app''s side of the process, something like: >> >> ... >> TIMEOUT_SECS = 10 # or whatever the max should be. >> >> ... >> timeout_status = nil >> begin >> timeout_status = Timeout::timeout(TIMEOUT_SECS) do >> # do stuff that might take too long .... >> end >> rescue Timeout::Error => te >> # log it and ... >> end >> ... >> >> Jeff >> >> >> On Apr 1, 11:18 am, Marcelo de Moraes Serpa <celose...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote: >> > Hello list, >> > >> > Does anyone know if ruby-ldap supports connection timeouts? We have LDAP >> > integrated into our authentication system to provide LDAP authentication >> as >> > well. It works fine if you input a valid host/port and if the LDAP >> server is >> > responding ok. However, if the host doesn''t respond for some reason >> (could >> > be an invalid IP), ruby-ldap hangs there waiting forever, hanging the >> > application, something that obvisouly could cause potential problems >> (since >> > it uses passenger). >> > >> > Any ideas on how to handle that? >> > >> > Thanks, >> > >> > Marcelo. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
*bump* Does anyone have any idea on why it fails? Marcelo. On Fri, Apr 2, 2010 at 8:50 PM, Marcelo de Moraes Serpa <celoserpa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Correction. SystemTimer works when binding, but *does not work* with the > search / search2 method(s). If the LDAP server hangs for any reason, > SystemTimer fails to kill the thread, and even though the Timeout::Error > exception is thrown, it is only after much more time than what you define in > the timeout_after(time) method. > > I''ve tried to contact Philippe, the author regarding this, let''s see how it > goes. Meanwhile, if anyone has a clue on why it is failing, please share! > > Cheers, > > Marcelo. > > > On Thu, Apr 1, 2010 at 4:09 PM, Marcelo de Moraes Serpa < > celoserpa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hi Jeff, >> >> Thanks! Every single day I''m amazed by what''s possible with Ruby, the more >> I learn, the less I know, but I guess that''s good :) >> >> This led me to the SystemTimer gem. The Timeout class was failing, I guess >> because it is external call that "cross the barriers", as explained here: >> http://ph7spot.com/musings/system-timer). SystemTimer works like a charm >> ;) >> >> Cheers, >> >> Marcelo. >> >> >> On Thu, Apr 1, 2010 at 1:21 PM, Jeff Lewis <jeff.burly-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> Hi Marcelo, >>> >>> If that ldap lib doesn''t include any timeout settings/params for >>> timing out long-running ldap calls (which if you''re talking about ruby- >>> net-ldap, it doesn''t at this time), then one way would be to wrap >>> those potentially-long-running calls in ruby''s timeout (http://ruby- >>> doc.org/core/classes/Timeout.html) to at least force a timeout on your >>> app''s side of the process, something like: >>> >>> ... >>> TIMEOUT_SECS = 10 # or whatever the max should be. >>> >>> ... >>> timeout_status = nil >>> begin >>> timeout_status = Timeout::timeout(TIMEOUT_SECS) do >>> # do stuff that might take too long .... >>> end >>> rescue Timeout::Error => te >>> # log it and ... >>> end >>> ... >>> >>> Jeff >>> >>> >>> On Apr 1, 11:18 am, Marcelo de Moraes Serpa <celose...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>> wrote: >>> > Hello list, >>> > >>> > Does anyone know if ruby-ldap supports connection timeouts? We have >>> LDAP >>> > integrated into our authentication system to provide LDAP >>> authentication as >>> > well. It works fine if you input a valid host/port and if the LDAP >>> server is >>> > responding ok. However, if the host doesn''t respond for some reason >>> (could >>> > be an invalid IP), ruby-ldap hangs there waiting forever, hanging the >>> > application, something that obvisouly could cause potential problems >>> (since >>> > it uses passenger). >>> > >>> > Any ideas on how to handle that? >>> > >>> > Thanks, >>> > >>> > Marcelo. >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Ruby on Rails: Talk" group. >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >>> >> >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.