skip to Main Content

It seems there is some issue with the latest snowflake connector. I am trying to install it on Ubuntu OS and trying to connect to snowflake, but it gives the error AttributeError: 'SSLSocket' object has no attribute 'connection'

Here are the environment details:

I am using python version 3.5.2, ubuntu (Ubuntu 16.04.6 LTS) and also installed the latest snowflake python connector 2.2.6.

Here is the output of pip3 list

asn1crypto                 1.3.0
awscli                     1.11.13
azure-common               1.1.25
azure-storage-blob         2.1.0
azure-storage-common       2.1.0
blinker                    1.3
boto3                      1.13.7
botocore                   1.16.7
certifi                    2020.4.5.1
cffi                       1.13.2
chardet                    2.3.0
cloud-init                 19.4
colorama                   0.3.7
command-not-found          0.3
configobj                  5.0.6
cryptography               2.9.2
docutils                   0.12
hibagent                   1.0.1
idna                       2.0
ijson                      2.6.1
Jinja2                     2.8
jmespath                   0.9.0
jsonpatch                  1.10
jsonpointer                1.9
language-selector          0.1
MarkupSafe                 0.23
oauthlib                   1.0.3
oscrypto                   1.2.0
Pillow                     3.1.2
pip                        20.1
prettytable                0.7.2
pyasn1                     0.1.9
pycparser                  2.20
pycryptodomex              3.9.7
pycurl                     7.43.0
Pygments                   2.1
pygobject                  3.20.0
PyJWT                      1.3.0
pyOpenSSL                  19.1.0
pyserial                   3.0.1
python-apt                 1.1.0b1+ubuntu0.16.4.8
python-dateutil            2.4.2
python-debian              0.1.27
python-systemd             231
pytz                       2020.1
PyYAML                     3.11
requests                   2.9.1
roman                      2.0.0
rsa                        3.2.3
s3transfer                 0.3.3
setuptools                 46.2.0
six                        1.10.0
snowflake-connector-python 2.2.6
ssh-import-id              5.5
ufw                        0.35
unattended-upgrades        0.1
urllib3                    1.25.9
wheel                      0.34.2

I am using the sample python code mention in the snowflake documentation
https://docs.snowflake.com/en/user-guide/python-connector-install.html#step-2-verify-your-installation

Here is the error:

Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/network.py", line 799, in _request_exec
    auth=SnowflakeAuth(token),
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 480, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 588, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 376, in send
    timeout=timeout
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 677, in urlopen
    chunked=chunked,
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 976, in _validate_conn
    conn.connect()
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connection.py", line 370, in connect
    ssl_context=context,
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/ssl_wrap_socket.py", line 411, in ssl_wrap_socket_with_ocsp
    ).validate(server_hostname, ret.connection)
AttributeError: 'SSLSocket' object has no attribute 'connection'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/network.py", line 649, in _request_exec_wrapper
    **kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/network.py", line 892, in _request_exec
    raise RetryRequest(err)
snowflake.connector.network.RetryRequest: 'SSLSocket' object has no attribute 'connection'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/infaagent/apps/Data_Integration_Server/data/Scripts/test1.py", line 9, in <module>
    account='qsdunitydev'
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/__init__.py", line 53, in Connect
    return SnowflakeConnection(**kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/connection.py", line 189, in __init__
    self.connect(**kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/connection.py", line 493, in connect
    self.__open_connection()
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/connection.py", line 710, in __open_connection
    self.__authenticate(auth_instance)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/connection.py", line 964, in __authenticate
    session_parameters=self._session_parameters,
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/auth.py", line 216, in authenticate
    socket_timeout=self._rest._connection.login_timeout)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/network.py", line 530, in _post_request
    _include_retry_params=_include_retry_params)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/network.py", line 609, in fetch
    **kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/network.py", line 692, in _request_exec_wrapper
    conn, full_url, cause)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/network.py", line 722, in handle_invalid_certificate_error
    u'errno': ER_FAILED_TO_REQUEST,
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/errors.py", line 100, in errorhandler_wrapper
    connection.errorhandler(connection, cursor, errorclass, errorvalue)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/errors.py", line 73, in default_errorhandler
    done_format_msg=errorvalue.get(u'done_format_msg'))
snowflake.connector.errors.OperationalError: 250003: Failed to execute request: 'SSLSocket' object has no attribute 'connection'

2

Answers


  1. Can you run the below command to update the requests and then try

    pip3 install requests==2.23.0 
    

    Also if possible please upgrade the Python version to 3.7 and check if the issue persists or not.

    Login or Signup to reply.
  2. Downgrade the below packages, it worked for me.

    • asn1crypto 0.24.0 to asn1crypto 1.3.0
    • requests 2.27.1 to requests 2.22.0
    • SQLAlchemy 1.4.31 to SQLAlchemy 1.3.9
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search