Skip to content

Strange error undefined method 'result_code' #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dblessing opened this issue Apr 4, 2016 · 6 comments
Closed

Strange error undefined method 'result_code' #269

dblessing opened this issue Apr 4, 2016 · 6 comments

Comments

@dblessing
Copy link

In GitLab we're seeing an occasional error when we search for a group by CN. The stack is thrown deep within net/ldap. I'm still investigating to get more information from our side, but I'm posting the stack here in hopes it'll spark some thoughts on what might be causing this. The search filter only has a group base DN and group CN.

2016-04-04_13:23:25.50020 2016-04-04T13:23:25.500Z 8882 TID-v9x84 WARN: NoMethodError: undefined method `result_code' for nil:NilClass 
2016-04-04_13:23:25.50022 2016-04-04T13:23:25.500Z 8882 TID-v9x84 WARN: /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/net-ldap-0.12.1/lib/net/ldap/connection.rb:450:in `block (2 levels) in search' 
2016-04-04_13:23:25.50022 /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/net-ldap-0.12.1/lib/net/ldap/connection.rb:363:in `loop' 
2016-04-04_13:23:25.50023 /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/net-ldap-0.12.1/lib/net/ldap/connection.rb:363:in `block in search' 
2016-04-04_13:23:25.50023 /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/net-ldap-0.12.1/lib/net/ldap/instrumentation.rb:19:in `instrument' 
2016-04-04_13:23:25.50023 /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/net-ldap-0.12.1/lib/net/ldap/connection.rb:352:in `search' 
2016-04-04_13:23:25.50024 /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/net-ldap-0.12.1/lib/net/ldap.rb:753:in `block (2 levels) in search' 
2016-04-04_13:23:25.50024 /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/net-ldap-0.12.1/lib/net/ldap.rb:1223:in `use_connection' 
2016-04-04_13:23:25.50025 /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/net-ldap-0.12.1/lib/net/ldap.rb:752:in `block in search' 
2016-04-04_13:23:25.50025 /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/net-ldap-0.12.1/lib/net/ldap/instrumentation.rb:19:in `instrument' 
2016-04-04_13:23:25.50026 /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/net-ldap-0.12.1/lib/net/ldap.rb:751:in `search' 
@llaurent
Copy link

llaurent commented Jun 27, 2016

Hi there
I'm also encountering this issue.
that's just happened to me, hopefully I was tcpdump'ing :)
The ldap connection was closed by the LDAP server,
On the App server, the LDAP connection was in a CLOSE_WAIT state, despite that it tries to use it and gets a RST :
LDAP 330 searchRequest(7) "filtered" wholeSubtree
TCP 54 389→38298 [RST] Seq=1 Win=0 Len=0

Will try to reproduce this with ruby-ldap. (I'm using ActiveLDAP)
I'll probably circumvent this by setting a lower connection timeout on the app than on the server.

@llaurent
Copy link

This error I also encounter it with ruby 2.1, but I'm unable to reproduce it with 2.3.
Can anybody confirm ?

@gr790
Copy link

gr790 commented Jan 19, 2017

Hello,

I am also hit with this result_code nilClass bug, Could you please share how to propagate this error code to the application....Please let me know if you need more information.

@dgbtech
Copy link

dgbtech commented Feb 5, 2018

Hi,
I´m getting same error sometimes...

Searching in LDAP. undefined method result_code' for nil:NilClass: /vendor/bundle/ruby/2.1.0/gems/net-ldap-0.16.0/lib/net/ldap/connection.rb:485:in block (2 levels) in search'
I think that Ldap server is not answering.

@axelsteiner
Copy link

Hi,

I had the same exception and could reproduce it with with query / sleep 5 minutes / query again. I'm using OpenLDAP and figured out, that the idletimeout setting was the origin for the exception.

6.2.1.3. idletimeout
Specify the number of seconds to wait before forcibly closing an idle client connection. An
idletimeout of 0, the default, disables this feature.

If the default setting is active, there are no exceptions. When the connection hits the defined limit, net-ldap will raise the exception within the next query. It seems that net-ldap is not recognizing the lost connection correctly.

@guilhermewop
Copy link
Contributor

guilhermewop commented Mar 15, 2018

I'm experiencing the same exception:

undefined method `result_code' for nil:NilClass
Backtrace:
  /vendor/bundle/ruby/2.3.0/gems/net-ldap-0.16.1/lib/net/ldap/connection.rb:485:in `block (2 levels) in search'
  /vendor/bundle/ruby/2.3.0/gems/net-ldap-0.16.1/lib/net/ldap/connection.rb:399:in `loop'
  /vendor/bundle/ruby/2.3.0/gems/net-ldap-0.16.1/lib/net/ldap/connection.rb:399:in `block in search'
  /vendor/bundle/ruby/2.3.0/gems/net-ldap-0.16.1/lib/net/ldap/instrumentation.rb:19:in `instrument'
  /vendor/bundle/ruby/2.3.0/gems/net-ldap-0.16.1/lib/net/ldap/connection.rb:388:in `search'
...

In my case, I'm using OpenDJ behind the HAProxy load balancer and that error isn't raised when I connect my application on just one OpenDJ server.

Are you using load balancer with the directory server too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants