Apigee API raising SSL errors

Hi,

I’m facing issues with Apigee when I try to create apps or fetch app info through the apigee rest api. I’m using the google python client library for this.

Here’s the stack trace:

File “test_apigee.py”, line 7, in get_app_info
.execute()
^^^^^^^^^
File “/root/.venv/lib/python3.12/site-packages/googleapiclient/_helpers.py”, line 130, in positional_wrapper
return wrapped(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File “/root/.venv/lib/python3.12/site-packages/googleapiclient/http.py”, line 923, in execute
resp, content = _retry_request(
^^^^^^^^^^^^^^^
File “/root/.venv/lib/python3.12/site-packages/googleapiclient/http.py”, line 222, in _retry_request
raise exception
File “/root/.venv/lib/python3.12/site-packages/googleapiclient/http.py”, line 191, in _retry_request
resp, content = http.request(uri, method, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/root/.venv/lib/python3.12/site-packages/google_auth_httplib2.py”, line 218, in request
response, content = self.http.request(
^^^^^^^^^^^^^^^^^^
File “/root/.venv/lib/python3.12/site-packages/httplib2/init.py”, line 1724, in request
(response, content) = self._request(
^^^^^^^^^^^^^^
File “/root/.venv/lib/python3.12/site-packages/httplib2/init.py”, line 1444, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/root/.venv/lib/python3.12/site-packages/httplib2/init.py”, line 1367, in _conn_request
conn.request(method, request_uri, body, headers)
File “/usr/lib/python3.12/http/client.py”, line 1336, in request
self._send_request(method, url, body, headers, encode_chunked)
File “/usr/lib/python3.12/http/client.py”, line 1382, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “/usr/lib/python3.12/http/client.py”, line 1331, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “/usr/lib/python3.12/http/client.py”, line 1091, in _send_output
self.send(msg)
File “/usr/lib/python3.12/http/client.py”, line 1055, in send
self.sock.sendall(data)
File “/usr/lib/python3.12/ssl.py”, line 1211, in sendall
v = self.send(byte_view[count:])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.12/ssl.py”, line 1180, in send
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2406)

Does anyone know what might be causing this issue?

Hi @krsk - can you post your complete source code? I usually just use the googleapiclient to get an access token with https://www.googleapis.com/auth/cloud-platform scope, and then do normal REST calls with the token.. for example here’s a Typescript example - https://github.com/api-integration-samples/apigee-marketplace-sample/blob/main/src/routes/api/apigee/basepath/%2Bserver.ts

I’m sure there are similar python examples out there, don’t have one at hand though..

My code’s pretty standard, I feel. I don’t always get an error by the way - it’s intermittent. There’s no consistent way to reproduce it.

Not sure how to paste code samples in here, so apologies for the unformatted code dump


import google.auth
from google.api_core import retry
from googleapiclient import discovery
from googleapiclient.discovery import Resource

def get_app_info(organization_name: str, developer_email: str, sanitized_app_name: str :disappointed_face: 
credentials, _ = google.auth.default()
apigee: Resource = discovery.build("apigee", "v1", credentials=credentials)
return (apigee.organizations()
.developers()
.apps()
.get(
name=f"organizations/{organization_name}/developers/{developer_email}/apps/{sanitized_app_name}"
)
.execute()
)

did you happen to find any solve for this ?

for me this happens when i make api calls to different endpoints within same cloud run service. (External https calls)

No, unfortunately not

It seems this is a problem that occurs from time to time in python apps, independent of the use of apigee.googleapis.com. There are lots of suggestions out there, like check your proxy; disable IPv6; check your network connectivity. Good luck!