Hello list,
I have searched everywhere else, tesed extensively and came to a point where
I do not have a clue on what is happening.
I am using SystemTimer and Ruby/LDAP in my Rails application. Ruby/LDAP to
authenticate against a LDAP server and SystemTimer in an effort to avoid
potential long hangs.
Fact #1: SystemTimer works fine with the LDAP::Conn#bind method. It does cut
at the right time if it fails. However, for some unknowing mystic reason, it
just will not work with LDAP::Conn#search2.
The code I am using:
begin
arr = SystemTimer.timeout_after(5.seconds) do
connection.bind(self.bind_dn,self.password)
connection.search2(self.base_dn,1,"(&
(userPassword=#{password})
(mail=#{email}))",nil,false,5,5000)
end
rescue Exception => e
msg = ''LDAP server error.''
logger.error(logger_msg_template.call("#{msg} - Exception:
#{e.message}"))
raise Timeout::Error.new(msg)
end
So, if bind takes more than 5 seconds, timeout will throw the correctly
after 5 seconds. Good. If bind works, we then proceed to the search2 call.
Things get sensitive here. If for any reason the search2 delays too much,
the process is bound to just hang and wait for it''s return. Often it
happens
because the query is wrong (an attribute doesn''t exist in the LDAP
entry,
which might happen given the context of this code).
SystemTimer *does* throw the Timeout::Error ("time''s up!"),
but it just
doesn''t kill the Thread after the seconds specfied in the
timeout_after''s param. Check out this request that I just made:
ERROR: LDAP server error. - Exception: time''s up! - USER:
marcelo-1SZh+JHLGKk@public.gmane.org,
ACCOUNT: MyAccount, LDAP HOST: 89.150.80.164, PORT: 389.
SQL (0.3ms) ROLLBACK
Rendering template within layouts/application
Rendering directory/index
Completed in 34212ms (View: 19, DB: 7) | 200 OK [http://localhost/ldap]
Check the first line, it is from Rails'' logger. I also print the
exception
message, you can see that it was a "Time''s up!" (from
SystemTimer), but look
at how long it took: almost 35 seconds.
It is risky, since if many users are trying to setup a LDAP at the same
time, our service could just hang completely.
I''m really lost and really need some enlightenment here, any suggestion
appreciated!
Cheers,
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.
Forgot to include other relevant information: Rails 2.3.5, SystemTimer 1.2, ruby-ldap 0.9.11 all on Mac OSX Snow Leopard. Cheers, Marcelo. On Mon, Apr 5, 2010 at 5:06 PM, Marcelo de Moraes Serpa <celoserpa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello list, > > I have searched everywhere else, tesed extensively and came to a point > where I do not have a clue on what is happening. > > I am using SystemTimer and Ruby/LDAP in my Rails application. Ruby/LDAP to > authenticate against a LDAP server and SystemTimer in an effort to avoid > potential long hangs. > > Fact #1: SystemTimer works fine with the LDAP::Conn#bind method. It does > cut at the right time if it fails. However, for some unknowing mystic > reason, it just will not work with LDAP::Conn#search2. > > The code I am using: > > begin > arr = SystemTimer.timeout_after(5.seconds) do > connection.bind(self.bind_dn,self.password) > connection.search2(self.base_dn,1,"(& (userPassword=#{password}) > (mail=#{email}))",nil,false,5,5000) > end > rescue Exception => e > msg = ''LDAP server error.'' > logger.error(logger_msg_template.call("#{msg} - Exception: > #{e.message}")) > raise Timeout::Error.new(msg) > end > > So, if bind takes more than 5 seconds, timeout will throw the correctly > after 5 seconds. Good. If bind works, we then proceed to the search2 call. > Things get sensitive here. If for any reason the search2 delays too much, > the process is bound to just hang and wait for it''s return. Often it happens > because the query is wrong (an attribute doesn''t exist in the LDAP entry, > which might happen given the context of this code). > > SystemTimer *does* throw the Timeout::Error ("time''s up!"), but it just > doesn''t kill the Thread after the seconds specfied in the > timeout_after''s param. Check out this request that I just made: > > ERROR: LDAP server error. - Exception: time''s up! - USER: marcelo-1SZh+JHLGKk@public.gmane.org, > ACCOUNT: MyAccount, LDAP HOST: 89.150.80.164, PORT: 389. > SQL (0.3ms) ROLLBACK > Rendering template within layouts/application > Rendering directory/index > Completed in 34212ms (View: 19, DB: 7) | 200 OK [http://localhost/ldap] > > Check the first line, it is from Rails'' logger. I also print the exception > message, you can see that it was a "Time''s up!" (from SystemTimer), but look > at how long it took: almost 35 seconds. > > It is risky, since if many users are trying to setup a LDAP at the same > time, our service could just hang completely. > > I''m really lost and really need some enlightenment here, any suggestion > appreciated! > > Cheers, > > 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, Not to avoid your specific SystemTimer and ldap timeout issue, but .... Have you thought about trying the pure-ruby ldap lib Net::LDAP (http://net-ldap.rubyforge.org/) instead of the c-based Ruby/ LDAP lib you''re currently using (http://sourceforge.net/projects/ruby- ldap/)? I''ve always just used Net::LDAP whenever an app needed to auth against and/or query an ldap db, and have never had any problems with timing out un-responsive/too-long-running ldap connections using the regular old ruby Timeout (http://ruby-doc.org/core/classes/Timeout.html). If you can, I''d give Net::LDAP a chance to see if that doesn''t solve your problems. Jeff On Apr 5, 3:21 pm, Marcelo de Moraes Serpa <celose...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Forgot to include other relevant information: > > Rails 2.3.5, SystemTimer 1.2, ruby-ldap 0.9.11 all on Mac OSX Snow Leopard. > > Cheers, > > Marcelo. > > On Mon, Apr 5, 2010 at 5:06 PM, Marcelo de Moraes Serpa <celose...@gmail.com > > > > > wrote: > > Hello list, > > > I have searched everywhere else, tesed extensively and came to a point > > where I do not have a clue on what is happening. > > > I am using SystemTimer and Ruby/LDAP in my Rails application. Ruby/LDAP to > > authenticate against a LDAP server and SystemTimer in an effort to avoid > > potential long hangs. > > > Fact #1: SystemTimer works fine with the LDAP::Conn#bind method. It does > > cut at the right time if it fails. However, for some unknowing mystic > > reason, it just will not work with LDAP::Conn#search2. > > > The code I am using: > > > begin > > arr = SystemTimer.timeout_after(5.seconds) do > > connection.bind(self.bind_dn,self.password) > > connection.search2(self.base_dn,1,"(& (userPassword=#{password}) > > (mail=#{email}))",nil,false,5,5000) > > end > > rescue Exception => e > > msg = ''LDAP server error.'' > > logger.error(logger_msg_template.call("#{msg} - Exception: > > #{e.message}")) > > raise Timeout::Error.new(msg) > > end > > > So, if bind takes more than 5 seconds, timeout will throw the correctly > > after 5 seconds. Good. If bind works, we then proceed to the search2 call. > > Things get sensitive here. If for any reason the search2 delays too much, > > the process is bound to just hang and wait for it''s return. Often it happens > > because the query is wrong (an attribute doesn''t exist in the LDAP entry, > > which might happen given the context of this code). > > > SystemTimer *does* throw the Timeout::Error ("time''s up!"), but it just > > doesn''t kill the Thread after the seconds specfied in the > > timeout_after''s param. Check out this request that I just made: > > > ERROR: LDAP server error. - Exception: time''s up! - USER: marc...@site.com, > > ACCOUNT: MyAccount, LDAP HOST: 89.150.80.164, PORT: 389. > > SQL (0.3ms) ROLLBACK > > Rendering template within layouts/application > > Rendering directory/index > > Completed in 34212ms (View: 19, DB: 7) | 200 OK [http://localhost/ldap] > > > Check the first line, it is from Rails'' logger. I also print the exception > > message, you can see that it was a "Time''s up!" (from SystemTimer), but look > > at how long it took: almost 35 seconds. > > > It is risky, since if many users are trying to setup a LDAP at the same > > time, our service could just hang completely. > > > I''m really lost and really need some enlightenment here, any suggestion > > appreciated! > > > Cheers, > > > 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.
Thanks, Jeff. This could be an alternative. However, we are lucky that the SystemTimer is working fine on Ubuntu. It''s just failing on my local dev box (An OSX Snow Leopard one) and I''m intrigued... Marcelo. On Mon, Apr 5, 2010 at 6:18 PM, Jeff Lewis <jeff.burly-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Marcelo, > > Not to avoid your specific SystemTimer and ldap timeout issue, > but .... Have you thought about trying the pure-ruby ldap lib > Net::LDAP (http://net-ldap.rubyforge.org/) instead of the c-based Ruby/ > LDAP lib you''re currently using (http://sourceforge.net/projects/ruby- > ldap/ <http://sourceforge.net/projects/ruby-%0Aldap/>)? > > I''ve always just used Net::LDAP whenever an app needed to auth against > and/or query an ldap db, and have never had any problems with timing > out un-responsive/too-long-running ldap connections using the regular > old ruby Timeout (http://ruby-doc.org/core/classes/Timeout.html). If > you can, I''d give Net::LDAP a chance to see if that doesn''t solve your > problems. > > Jeff > > On Apr 5, 3:21 pm, Marcelo de Moraes Serpa <celose...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Forgot to include other relevant information: > > > > Rails 2.3.5, SystemTimer 1.2, ruby-ldap 0.9.11 all on Mac OSX Snow > Leopard. > > > > Cheers, > > > > Marcelo. > > > > On Mon, Apr 5, 2010 at 5:06 PM, Marcelo de Moraes Serpa < > celose...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > > > > > > > > wrote: > > > Hello list, > > > > > I have searched everywhere else, tesed extensively and came to a point > > > where I do not have a clue on what is happening. > > > > > I am using SystemTimer and Ruby/LDAP in my Rails application. Ruby/LDAP > to > > > authenticate against a LDAP server and SystemTimer in an effort to > avoid > > > potential long hangs. > > > > > Fact #1: SystemTimer works fine with the LDAP::Conn#bind method. It > does > > > cut at the right time if it fails. However, for some unknowing mystic > > > reason, it just will not work with LDAP::Conn#search2. > > > > > The code I am using: > > > > > begin > > > arr = SystemTimer.timeout_after(5.seconds) do > > > connection.bind(self.bind_dn,self.password) > > > connection.search2(self.base_dn,1,"(& > (userPassword=#{password}) > > > (mail=#{email}))",nil,false,5,5000) > > > end > > > rescue Exception => e > > > msg = ''LDAP server error.'' > > > logger.error(logger_msg_template.call("#{msg} - Exception: > > > #{e.message}")) > > > raise Timeout::Error.new(msg) > > > end > > > > > So, if bind takes more than 5 seconds, timeout will throw the correctly > > > after 5 seconds. Good. If bind works, we then proceed to the search2 > call. > > > Things get sensitive here. If for any reason the search2 delays too > much, > > > the process is bound to just hang and wait for it''s return. Often it > happens > > > because the query is wrong (an attribute doesn''t exist in the LDAP > entry, > > > which might happen given the context of this code). > > > > > SystemTimer *does* throw the Timeout::Error ("time''s up!"), but it just > > > doesn''t kill the Thread after the seconds specfied in the > > > timeout_after''s param. Check out this request that I just made: > > > > > ERROR: LDAP server error. - Exception: time''s up! - USER: > marc...-1SZh+JHLGKk@public.gmane.org, > > > ACCOUNT: MyAccount, LDAP HOST: 89.150.80.164, PORT: 389. > > > SQL (0.3ms) ROLLBACK > > > Rendering template within layouts/application > > > Rendering directory/index > > > Completed in 34212ms (View: 19, DB: 7) | 200 OK [http://localhost/ldap > ] > > > > > Check the first line, it is from Rails'' logger. I also print the > exception > > > message, you can see that it was a "Time''s up!" (from SystemTimer), but > look > > > at how long it took: almost 35 seconds. > > > > > It is risky, since if many users are trying to setup a LDAP at the same > > > time, our service could just hang completely. > > > > > I''m really lost and really need some enlightenment here, any suggestion > > > appreciated! > > > > > Cheers, > > > > > 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.
Hello.. Can anyone tell me how to get off this mailing list?
________________________________
From: Marcelo de Moraes Serpa
<celoserpa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Sent: Mon, April 5, 2010 5:06:50 PM
Subject: [Rails] SystemTimer failing
Hello list,
I have searched everywhere else, tesed extensively and came to a point where I
do not have a clue on what is happening.
I am using SystemTimer and Ruby/LDAP in my Rails application. Ruby/LDAP to
authenticate against a LDAP server and SystemTimer in an effort to avoid
potential long hangs.
Fact #1: SystemTimer works fine with the LDAP::Conn#bind method. It does cut at
the right time if it fails. However, for some unknowing mystic reason, it just
will not work with LDAP::Conn#search2.
The code I am using:
begin
arr = SystemTimer.timeout_after(5.seconds) do
connection.bind(self.bind_dn,self.password)
connection.search2(self.base_dn,1,"(&
(userPassword=#{password}) (mail=#{email}))",nil,false,5,5000)
end
rescue Exception => e
msg = ''LDAP server error.''
logger.error(logger_msg_template.call("#{msg} - Exception:
#{e.message}"))
raise Timeout::Error.new(msg)
end
So, if bind takes more than 5 seconds, timeout will throw the correctly after 5
seconds. Good. If bind works, we then proceed to the search2 call. Things get
sensitive here. If for any reason the search2 delays too much, the process is
bound to just hang and wait for it''s return. Often it happens because
the query is wrong (an attribute doesn''t exist in the LDAP entry, which
might happen given the context of this code).
SystemTimer *does* throw the Timeout::Error ("time''s up!"),
but it just doesn''t kill the Thread after the seconds specfied in the
timeout_after''s param. Check out this request that I just made:
ERROR: LDAP server error. - Exception: time''s up! - USER:
marcelo-1SZh+JHLGKk@public.gmane.org, ACCOUNT: MyAccount, LDAP HOST:
89.150.80.164, PORT: 389.
SQL (0.3ms) ROLLBACK
Rendering template within layouts/application
Rendering directory/index
Completed in 34212ms (View: 19, DB: 7) | 200 OK [http://localhost/ldap]
Check the first line, it is from Rails'' logger. I also print the
exception message, you can see that it was a "Time''s up!"
(from SystemTimer), but look at how long it took: almost 35 seconds.
It is risky, since if many users are trying to setup a LDAP at the same time,
our service could just hang completely.
I''m really lost and really need some enlightenment here, any suggestion
appreciated!
Cheers,
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.
--
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.
No, I can''t tell you. First, because it has nothing to do with the topic of this message, seconds, because it is obvious it is GoogleGroups, and it is simple enough to cancel the subscription, and third, because a simple google search is enough to get very clear instructions. Gee, this list needs some moderation. Marcelo. On Mon, Apr 5, 2010 at 10:47 PM, Todd Reeves <todd.reeves-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> Hello.. Can anyone tell me how to get off this mailing list? > > ------------------------------ > *From:* Marcelo de Moraes Serpa <celoserpa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > *To:* rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > *Sent:* Mon, April 5, 2010 5:06:50 PM > *Subject:* [Rails] SystemTimer failing > > Hello list, > > I have searched everywhere else, tesed extensively and came to a point > where I do not have a clue on what is happening. > > I am using SystemTimer and Ruby/LDAP in my Rails application. Ruby/LDAP to > authenticate against a LDAP server and SystemTimer in an effort to avoid > potential long hangs. > > Fact #1: SystemTimer works fine with the LDAP::Conn#bind method. It does > cut at the right time if it fails. However, for some unknowing mystic > reason, it just will not work with LDAP::Conn#search2. > > The code I am using: > > begin > arr = SystemTimer.timeout_after(5.seconds) do > connection.bind(self.bind_dn,self.password) > connection.search2(self.base_dn,1,"(& (userPassword=#{password}) > (mail=#{email}))",nil,false,5,5000) > end > rescue Exception => e > msg = ''LDAP server error.'' > logger.error(logger_msg_template.call("#{msg} - Exception: > #{e.message}")) > raise Timeout::Error.new(msg) > end > > So, if bind takes more than 5 seconds, timeout will throw the correctly > after 5 seconds. Good. If bind works, we then proceed to the search2 call. > Things get sensitive here. If for any reason the search2 delays too much, > the process is bound to just hang and wait for it''s return. Often it happens > because the query is wrong (an attribute doesn''t exist in the LDAP entry, > which might happen given the context of this code). > > SystemTimer *does* throw the Timeout::Error ("time''s up!"), but it just > doesn''t kill the Thread after the seconds specfied in the > timeout_after''s param. Check out this request that I just made: > > ERROR: LDAP server error. - Exception: time''s up! - USER: marcelo-1SZh+JHLGKk@public.gmane.org, > ACCOUNT: MyAccount, LDAP HOST: 89.150.80.164, PORT: 389. > SQL (0.3ms) ROLLBACK > Rendering template within layouts/application > Rendering directory/index > Completed in 34212ms (View: 19, DB: 7) | 200 OK [http://localhost/ldap] > > Check the first line, it is from Rails'' logger. I also print the exception > message, you can see that it was a "Time''s up!" (from SystemTimer), but look > at how long it took: almost 35 seconds. > > It is risky, since if many users are trying to setup a LDAP at the same > time, our service could just hang completely. > > I''m really lost and really need some enlightenment here, any suggestion > appreciated! > > Cheers, > > 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-/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.