Open SteEcker opened 1 month ago
connection.py
Hi again,
I did some digging and identified the potential root cause of the issue with the KeycloakOpenID
client timing out when connecting through a proxy.
In the connection.py
file, the relevant line:
self.async_s = httpx.AsyncClient(verify=verify, proxies=proxies, cert=cert)
passes the proxies argument to the httpx.AsyncClient. However, upon reviewing the httpx.AsyncClient class, I noticed that the proxies argument has been deprecated and should be replaced with the proxy argument. Here’s the key part from the documentation:
class AsyncClient(BaseClient):
<...>
if proxies:
message = (
"The 'proxies' argument is now deprecated."
" Use 'proxy' or 'mounts' instead."
)
warnings.warn(message, DeprecationWarning)
This means that using proxies as it's currently done in the ConnectionManager class triggers this deprecation warning and might be causing the timeout issue.
I changed the client call to
self.async_s = httpx.AsyncClient(verify=verify, proxy=proxies["http"], cert=cert)
After making this change, the client successfully connects 🎉
Hi, thank you for this package!
Describe the issue
I am trying to use the
KeycloakOpenID
client in Python to connect to a Keycloak server behind a proxy, specifying a custom certificate for SSL verification, but I encounter a timeout when the client attempts to retrieve the.well-known/openid-configuration
endpoint for my realm. The direct connection to the base Keycloak URL works successfully using therequests
library, but thewell_known()
method in theKeycloakOpenID
client times out when trying to access the OpenID configuration.Direct Request Test (Success)
When I use the
requests
package directly with the same proxy and certificate settings, I can successfully reach the Keycloak server:So I can confirm that my proxy settings are correct.
However, when I attempt to use the KeycloakOpenID client with the same proxy and certificate settings, the connection to the /.well-known/openid-configuration endpoint fails due to a timeout:
Logs:
Is the proxy configuration that I am passing into the KeycloakOpenID client correct?
Environment
Python version: 3.11.6 python-keycloak==4.5.1