twisted / ldaptor

LDAP server, client and utilities, using Twisted Python
MIT License
160 stars 53 forks source link

Merger example - Connection lost #231

Open FandaOG opened 3 years ago

FandaOG commented 3 years ago

Hi,

I use merger https://ldaptor.readthedocs.io/en/latest/cookbook/merger.html I've got a problem. I have 2 LDAP servers. Sometime one LDAP server is offline. How can I handle if LDAP is offline (1st is online 2nd is offline I expect I should get response from 1st LDAP but I got infinite pending loop)? Thanks.

Current behavior is:

  1. request ldapsearch -x -H ldap://merger.test:389 "uid=test"
  2. I get error on merger server:

    2021-07-22T09:16:33+0000 [twisted.internet.defer#critical] 
    
    Traceback (most recent call last):
    
      File "/usr/local/lib/python3.8/site-packages/twisted/internet/defer.py", line 330, in addCallbacks
        self._runCallbacks()
    
      File "/usr/local/lib/python3.8/site-packages/twisted/internet/defer.py", line 662, in _runCallbacks
        current.result = callback(current.result, *args, **kw)
    
      File "/usr/local/lib/python3.8/site-packages/ldaptor/protocols/ldap/merger.py", line 120, in _handleUnknown
        self._whenConnected(self._clientQueue, request, controls, reply)
    
      File "/usr/local/lib/python3.8/site-packages/ldaptor/protocols/ldap/merger.py", line 36, in _whenConnected
        return defer.maybeDeferred(fn, *a, **kw)
    
    --- <exception caught here> ---
    
      File "/usr/local/lib/python3.8/site-packages/twisted/internet/defer.py", line 167, in maybeDeferred
    
        result = f(*args, **kw)
    
      File "/usr/local/lib/python3.8/site-packages/ldaptor/protocols/ldap/merger.py", line 59, in _clientQueue
        d = c.send_multiResponse(request, self._gotResponse, reply)
    
      File "/usr/local/lib/python3.8/site-packages/ldaptor/protocols/ldap/ldapclient.py", line 128, in send_multiResponse
        msg = self._send(op)
    
      File "/usr/local/lib/python3.8/site-packages/ldaptor/protocols/ldap/ldapclient.py", line 81, in _send
        raise LDAPClientConnectionLostException()
    
    ldaptor.protocols.ldap.ldapclient.LDAPClientConnectionLostException: Connection lost
  3. ldapsearch does not get the response (one user exists) it is in infinite pending on data