amazon-redshift-python-driver icon indicating copy to clipboard operation
amazon-redshift-python-driver copied to clipboard

Error when establish the connection Redshift Serverless

Open amzar96 opened this issue 10 months ago • 0 comments

Driver version

2.1.5

Redshift version

PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.80583

Client Operating System

Linux

Python version

3.12

Table schema

Not required

Problem description

  1. Expected behaviour: Established connection
  2. Actual behaviour: Failed to connect
  3. Error message/stack trace: redshift_connector.error.InterfaceError: ('communication error', SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1000)'))
  4. Any other details that can be helpful:

Python Driver trace logs

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/redshift_connector/core.py", line 671, in __init__
    self._usock = ssl_context.wrap_socket(self._usock)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/ssl.py", line 455, in wrap_socket
    return self.sslsocket_class._create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/ssl.py", line 1042, in _create
    self.do_handshake()
  File "/usr/local/lib/python3.12/ssl.py", line 1320, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLEOFError: [SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1000)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/helper/redshift_helper.py", line 22, in create_connection
    _conn = rc.connect(
            ^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/redshift_connector/__init__.py", line 394, in connect
    return Connection(
           ^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/redshift_connector/core.py", line 698, in __init__
    raise InterfaceError("communication error", e)
redshift_connector.error.InterfaceError: ('communication error', SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1000)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/main.py", line 26, in <module>
    main()
  File "/app/main.py", line 18, in main
    ds.auto_create_views()
  File "/app/function/datashare.py", line 35, in auto_create_views
    self.rs_public2 = RedshiftHelper(
                      ^^^^^^^^^^^^^^^
  File "/app/helper/redshift_helper.py", line 18, in __init__
    self._conn = self.create_connection()
                 ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/helper/redshift_helper.py", line 31, in create_connection
    raise Exception(str(e))
Exception: ('communication error', SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1000)'))

Reproduction code

code snippet

def create_connection(self):
    try:
        _conn = rc.connect(
            host=self._host,
            port=self._port,
            database=self._database,
            user=self._user,
            password=self._password,
        )
    except Exception as e:
        logger.error(f"failed connect to ({self._host}), {str(e)}")
        raise Exception(str(e))

    _conn.autocommit = True

    logger.info(f"redshift connection ({self._host}) established...")

    return _conn

amzar96 avatar Dec 31 '24 01:12 amzar96