Thanks to visit codestin.com
Credit goes to github.com

Skip to content

symfony/ldap fails eventually in worker mode #53442

Open
@ili101

Description

@ili101

Symfony version(s) affected

6.4.0

Description

For reference, this issue started from here php/frankenphp#457
In worker mode, the https://github.com/symfony/ldap/blob/6.4/Adapter/ExtLdap/Connection.php is persistent between executions.
So __destruct() and disconnect() are not executed for the lifetime of the worker.
After some time the bind session inevitably gets invalidated by the network, LDAP server, or any other participant.
At this point symfony/ldap will use the invalid bind and throw an error for all login attempts from this point.

How to reproduce

Run Symfony in worker mode, for example run https://github.com/dunglas/symfony-docker in production mode.
Setup symfony/ldap authentication.
Notice that on authentication (after some execution so workers will start to get reused) you stop seeing new binding but only existing connections get used.
Wait for the session to get invalid or find a way to invalidate it.
From this point, all authentication on the worker will fail with:
"message": "Uncaught PHP Exception Symfony\\Component\\Ldap\\Exception\\ConnectionException: \"Can't contact LDAP server\" at Connection.php line 86",

Possible Solution

If the desired setup is that in worker mode we keep using the same connection then the code needs to recover it and rebind when it stops working eventually.
Or if we want it to work as it works now not in worker mode then there needs to be something to disconnect() it somehow when the request ends (as __destruct() not executed between requests).

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions