You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under normal load, the library works fine but when load increases I start to get below error
File "/usr/local/lib/python3.8/site-packages/django_cognito_jwt/validator.py", line 30, in _json_web_keys
response = requests.get(self.pool_url + "/.well-known/jwks.json")
File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='cognito-idp.xx-xxxx.amazonaws.com', port=443): Max retries exceeded with url: /us-west-2_xxxxxxxxxx/.well-known/jwks.json (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f72c1d67400>: Failed to establish a new connection: [Errno -2] Name does not resolve'))
I propose to initialize the token_validator just once in backend.py like below
class JSONWebTokenAuthentication(BaseAuthentication):
"""Token based authentication using the JSON Web Token standard."""
token_validator = None
def authenticate(self, request):
"""Entrypoint for Django Rest Framework"""
jwt_token = self.get_jwt_token(request)
if jwt_token is None:
return None
if not self.token_validator:
self.token_validator = self.get_token_validator(request)
# Authenticate token
try:
#token_validator = self.get_token_validator(request)
jwt_payload = self.token_validator.validate(jwt_token)
except TokenError as e:
raise exceptions.AuthenticationFailed()
The text was updated successfully, but these errors were encountered:
Hi,
Under normal load, the library works fine but when load increases I start to get below error
I propose to initialize the
token_validator
just once in backend.py like belowThe text was updated successfully, but these errors were encountered: