firebase-admin-python icon indicating copy to clipboard operation
firebase-admin-python copied to clipboard

Firebase with Python 3.9 giving an SSL error

Open ankitmaloo opened this issue 3 years ago • 3 comments

[READ] Step 1: Are you in the right place?

Step 2: Describe your environment

  • Operating System version: MAC OSX 11.6 BIg Sur
  • Firebase SDK version: 5.0.2
  • Firebase Product: firestore/ admin SDK (auth, database, storage, etc)
  • Python version: 3.9
  • Pip version: 22.0.3

[REQUIRED] Step 3: Describe the problem

I am trying to use admin SDK to connect to firebase - using the service account JSON file. It gives SSL issue. precisely: google.api_core.exceptions.RetryError: Deadline of 300.0s exceeded while calling functools.partial(<function _wrap_stream_errors..error_remapped_callable at 0x10fec7310>, parent: "projects/noomi-d9a4e/databases/(default)/documents"

Steps to reproduce:

I can tell how I am getting it. It was working fine when I last checked - a month back. I just tried to access one collection in Firestore and got this error.

Relevant Code:

docs = db.collection("users").where("username", "==", "access").stream()


cred = credentials.Certificate("./firebase.json")
firebase_admin.initialize_app(cred)

db = firestore.client()
docs = db.collection("users").where("username", "==", "access").stream()

Stack Trace if needed

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/google/api_core/retry.py", line 184, in retry_target return target() File "/usr/local/lib/python3.9/site-packages/google/api_core/grpc_helpers.py", line 168, in error_remapped_callable six.raise_from(exceptions.from_grpc_error(exc), exc) File "", line 3, in raise_from google.api_core.exceptions.ServiceUnavailable: 503 Getting metadata from plugin failed with error: HTTPSConnectionPool(host='oauth2.googleapis.com', port=443): Max retries exceeded with url: /token (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Users/a/Desktop/test/noomi_backend/weeklyNotif.py", line 52, in get_members() File "/Users/a/Desktop/test/noomi_backend/weeklyNotif.py", line 40, in get_members for doc in docs: File "/usr/local/lib/python3.9/site-packages/google/cloud/firestore_v1/query.py", line 208, in stream response_iterator = self._client._firestore_api.run_query( File "/usr/local/lib/python3.9/site-packages/google/cloud/firestore_v1/services/firestore/client.py", line 965, in run_query response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) File "/usr/local/lib/python3.9/site-packages/google/api_core/gapic_v1/method.py", line 145, in call return wrapped_func(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/google/api_core/retry.py", line 281, in retry_wrapped_func return retry_target( File "/usr/local/lib/python3.9/site-packages/google/api_core/retry.py", line 199, in retry_target six.raise_from( File "", line 3, in raise_from google.api_core.exceptions.RetryError: Deadline of 300.0s exceeded while calling functools.partial(<function wrap_stream_errors..error_remapped_callable at 0x10fec7310>, parent: "projects/<> /databases/(default)/documents" structured_query { from { collection_id: "users" } where { field_filter { field { field_path: "username" } op: EQUAL value { string_value: "access" } } } } , metadata=[('google-cloud-resource-prefix', 'projects/noomi-d9a4e/databases/(default)'), ('x-goog-request-params', 'parent=projects/<>/databases/%28default%29/documents'), ('x-goog-api-client', 'gl-python/3.9.5 grpc/1.37.1 gax/1.26.3 gapic/2.1.1')]), last exception: 503 Getting metadata from plugin failed with error: HTTPSConnectionPool(host='oauth2.googleapis.com', port=443): Max retries exceeded with url: /token (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))

ankitmaloo avatar Feb 16 '22 10:02 ankitmaloo

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Feb 16 '22 10:02 google-oss-bot

Could be an openssl issue in your environment. Check your openssl version by running openssl version. If you can reproduce it please file an issue in google-cloud/firestore repo.

lahirumaramba avatar Feb 16 '22 20:02 lahirumaramba

Hi @lahirumaramba On running openssl version, I get this output LibreSSL 2.8.3

How do I fix this and get to the working SSL version? Please let me know what I can do from my end. I also ran python3 -c "import ssl; print(ssl.OPENSSL_VERSION)" and got the output as OpenSSL 1.1.1m 14 Dec 2021. What do i need to do to get firebase working again?

ankitmaloo avatar Feb 16 '22 20:02 ankitmaloo