Uploaded image for project: 'Couchbase Python Client Library'
  1. Couchbase Python Client Library
  2. PYCBC-1470

Unable to connect to serverless instances using Python sdk on lambda function

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • None
    • None
    • None
    • 0

    Description

      Hi Jared,
      As discussed i am creating this ticket to outline the steps we take to build the lambda for python.
       The lambda for python contains the source code along with the shared libraries and the layer contains the Sdk.

      • We copy the source code for playground along with the shared libraries libssl.so.1.1 and libcrypto.so.1.1 into a zip file and upload it to AWS lambda.
      • The zip file can be uploaded on AWS Lambda as the source code bundle.More details can be found here https://docs.aws.amazon.com/lambda/latest/dg/python-package.html
      • We upload the couchbase python sdk as a layer to the lambda by running the below command on a linux machine and creating a zip.( Basically copy to python/lib/python3.9/site-packages)
      • python3 -m pip install --target python/lib/python3.9/site-packages/ -r src/requirements.txt
      • strip --strip-debug python/lib/python3.9/site-packages/couchbase/pycbc_core.so
      • zip -r layer.zip python
        The requirements.txt contains couchbase==4.1.2 and requests==2.28.1
      • The zip can be used to create a layer on lambda.

      When I test the packaged lambda for a provisioned production instance it works as expected, but the same code replaced with serverless prod credentials throws an error in the SDK (tls process server certificate error).
      If i diable tls in the connection string in the code(using conn.cloud.couchbase.com?tls_verify=no_verify) for the same serverless instance, it works as expected.

      I have tested the example running locally on a ubuntu 20.04 LTS and it works. I also copied over the shared libraries (which is present here /usr/lib/x86_64-linux-gnu/) to the lambda and rebuilt the zip just to confirm that the libraries are up to date.

      I will be attaching the SDK logs and also the code example being used. Please Let me know if you need any other info from our side.

      Code used :

      from couchbase.cluster import Cluster
      from couchbase.options import ClusterOptions
      from couchbase.auth import PasswordAuthenticator

      pa = PasswordAuthenticator.ldap_compatible('something', 'something')
      options = ClusterOptions(pa)
      options.apply_profile('wan_development')
      cluster = Cluster('ax-cloud.couchbase.com', options)

      bucket = cluster.bucket('ac-0gep22')
      collection = bucket.scope('samples').collection('airline')

      try:
      result = collection.get('airline_10')
      print(result.content_as[dict])

      except Exception as e:
      print("exception:", e)

      Attachments

        1. openssl11.zip
          1.81 MB
        2. sdk_logs.txt
          23 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jared.casey Jared Casey
            prajwal.pai Prajwal Pai
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty