aws / aws/amazon-redshift-python-driver

Error when establish the connection Redshift Serverless

未關閉
#249 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
220
分支
86
PR 合併指標
30 天內沒有已合併 PR

描述

## 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
```log
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
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
```python
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
```

貢獻指南

開啟貢獻指南

研究方向

首先,使用提供的 Python 程式碼片段重現連線,並檢查 redshift_connector/core.py 中 Connection 初始化以及 trace 所示的 ssl_context.wrap_socket 呼叫附近的程式碼。將所回報的 Redshift Serverless 環境中的行為與文件記載的連線參數進行比較;完成的標準是找出可重現的驅動程式端原因,並驗證連線能夠成功建立。報告中沒有指定 repository test。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
databases
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。