Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

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?

0 3 79
3 REPLIES 3

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...

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😞
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()
)
```