Skip to content
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

Occasional rpcclient errors #64

Open
UgnilJoZ opened this issue Mar 24, 2023 · 7 comments
Open

Occasional rpcclient errors #64

UgnilJoZ opened this issue Mar 24, 2023 · 7 comments

Comments

@UgnilJoZ
Copy link

Hi,

Every second time we call /setpassword, an error is shown: "rpcclient is already connected".

Screenshot(2) (1)

Manually resending the request succeeds.

If not catched, the exeption trace is the following:

Traceback (most recent call last):
  File "/opt/data/IPAPasswordReset/PasswordReset/app/views.py", line 49, in post
    PasswdManager().second_phase(request.POST['uid'], request.POST['token'], request.POST['password1'])
  File "/opt/data/IPAPasswordReset/PasswordReset/app/pwdmanager.py", line 43, in __init__
    api.Backend.rpcclient.connect()
  File "/usr/lib/python3.9/site-packages/ipalib/backend.py", line 62, in connect
    raise Exception(
Exception: rpcclient is already connected (rpcclient_139845700820416 in Thread-2)
@UgnilJoZ UgnilJoZ changed the title Spurious rpcclient errors Occasional rpcclient errors Mar 29, 2023
@vmario89
Copy link

i can confirm this issue. i used https://github.com/eaudeweb/freeipa-password-reset fork to make it run in general. First try to reset worked, second gave that RPC warning to me too

@vmario89
Copy link

vmario89 commented Jun 12, 2023

ok. this error happens so often in a row thats quite impossible to reset a password for a user. the token is sent by mail, but when i enter i get the error nearly always. had to re-enter the token and new password 5 times until it worked.

some info about version:

  • ipaclient version is 4.8.9,
  • FreeIPA 4.9.11
  • Fedora 36

@vmario89
Copy link

same issue happens when NOT using virtualenv, instead using the system's provided python libraries. With ipaclient version 4.9.11 (same like FreeIPA server itself) it happens the same way

@vmario89
Copy link

@vmario89
Copy link

vmario89 commented Jun 12, 2023

dirty bug fix like the following works:

vim /srv/IPAPasswordReset/PasswordReset/app/pwdmanager.py

        api.Backend.rpcclient.connect()
        self.redis = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB, password=settings.REDIS_PASSWORD)

add a try-except block before connect() method

        try:
            api.Backend.rpcclient.disconnect()
        except Exception as e:
            pass
            
        api.Backend.rpcclient.connect()
        self.redis = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB, password=settings.REDIS_PASSWORD)

@UgnilJoZ
Copy link
Author

UgnilJoZ commented Jun 12, 2023

A cleaner solution could be to let the call to api.Backend.rpcclient.connect() depend on the connection status, which can be queried through the isconnected method. This should also fix the issue.

@vmario89
Copy link

vmario89 commented Jun 12, 2023

hi. Yeah indeed this is better:

vim /srv/IPAPasswordReset/PasswordReset/app/pwdmanager.py

        api.Backend.rpcclient.connect()
        self.redis = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB, password=settings.REDIS_PASSWORD)

should get

        if api.Backend.rpcclient.isconnected() is False:
            api.Backend.rpcclient.connect()
        self.redis = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB, password=settings.REDIS_PASSWORD)

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

2 participants