add retry to keycloak connection
This commit is contained in:
parent
b8ab7da1a9
commit
4505ddd0ee
|
@ -1,3 +1,4 @@
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -25,6 +26,14 @@ logging.getLogger('oic').setLevel(logging.INFO)
|
||||||
async def connect_auth_client(app, loop):
|
async def connect_auth_client(app, loop):
|
||||||
client.allow["issuer_mismatch"] = True
|
client.allow["issuer_mismatch"] = True
|
||||||
client.provider_config(app.config.KEYCLOAK_URL)
|
client.provider_config(app.config.KEYCLOAK_URL)
|
||||||
|
try:
|
||||||
|
client.provider_config(app.config.KEYCLOAK_URL)
|
||||||
|
except:
|
||||||
|
log.exception(f"could not connect to {app.config.KEYCLOAK_URL}")
|
||||||
|
log.info("will retry")
|
||||||
|
await asyncio.sleep(2)
|
||||||
|
log.info("retrying")
|
||||||
|
await connect_auth_client(app,loop)
|
||||||
client.store_registration_info(
|
client.store_registration_info(
|
||||||
RegistrationResponse(
|
RegistrationResponse(
|
||||||
client_id=app.config.KEYCLOAK_CLIENT_ID,
|
client_id=app.config.KEYCLOAK_CLIENT_ID,
|
||||||
|
|
Loading…
Reference in a new issue