S3へアクセスする際に例外エラーが発生してアクセスできません。
対処方法などあれば教えて頂けませんでしょうか。
プロキシ周りの設定を変更する必要があるのかその辺りの知見がなく、アドバイス頂けると幸いです。
よろしくお願いします。
実行環境
ネットワーク: 社内ネットワーク
Windows10 Pro
Python 3.7.9
各パッケージ
Package Version
boto3 1.16.25
botocore 1.19.25
jmespath 0.10.0
pip 20.2.4
python-dateutil 2.8.1
s3transfer 0.3.3
selenium 3.141.0
setuptools 47.1.0
six 1.15.0
urllib3 1.26.2
wheel 0.35.1
発生している例外エラー
Traceback (most recent call last):
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 696, in urlopen
self._prepare_proxy(conn)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 964, in _prepare_proxy
conn.connect()
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 359, in connect
conn = self._connect_tls_proxy(hostname, conn)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 502, in _connect_tls_proxy
ssl_context=ssl_context,
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\ssl_.py", line 429, in ssl_wrap_socket
sock, context, tls_in_tls, server_hostname=server_hostname
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 423, in wrap_socket
session=session
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 870, in _create
self.do_handshake()
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] 既存の接続はリモート ホストに強制的に切断されました。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\httpsession.py", line 263, in send
chunked=self._chunked(request.headers),
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 756, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\retry.py", line 506, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
raise value.with_traceback(tb)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 696, in urlopen
self._prepare_proxy(conn)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 964, in _prepare_proxy
conn.connect()
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 359, in connect
conn = self._connect_tls_proxy(hostname, conn)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 502, in _connect_tls_proxy
ssl_context=ssl_context,
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\ssl_.py", line 429, in ssl_wrap_socket
sock, context, tls_in_tls, server_hostname=server_hostname
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 423, in wrap_socket
session=session
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 870, in _create
self.do_handshake()
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProxyError: ('Cannot connect to proxy.', ConnectionResetError(10054, '既存の接続はリモート ホストに強制的に切断されました。', None, 10054, None))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 7, in <module>
Prefix='sample/'
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\client.py", line 663, in _make_api_call
operation_model, request_dict, request_context)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\client.py", line 682, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\endpoint.py", line 102, in make_request
return self._send_request(request_dict, operation_model)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\endpoint.py", line 137, in _send_request
success_response, exception):
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\endpoint.py", line 256, in _needs_retry
caught_exception=caught_exception, request_dict=request_dict)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\hooks.py", line 356, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\hooks.py", line 228, in emit
return self._emit(event_name, kwargs)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\hooks.py", line 211, in _emit
response = handler(**kwargs)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 251, in __call__
caught_exception)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 277, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 317, in __call__
caught_exception)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 223, in __call__
attempt_number, caught_exception)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 359, in _check_caught_exception
raise caught_exception
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\endpoint.py", line 200, in _do_get_response
http_response = self._send(request)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\endpoint.py", line 269, in _send
return self.http_session.send(request)
File "C:\Users\user001\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\httpsession.py", line 285, in send
raise ProxyConnectionError(proxy_url=proxy_url, error=e)
botocore.exceptions.ProxyConnectionError: Failed to connect to proxy URL: "https://Proxy:8080"
コード
import boto3
client = boto3.client('s3')
response = client.list_objects(
Bucket='bucket001',
Prefix='sample/'
)
for item in response['Contents']:
print('{} : {}'.format(item['Key'],item['LastModified']))
Failed to connect to proxy URL: "https://Proxy:8080"
と表示されていますので、プロキシサーバの設定(環境変数HTTP_PROXY
,HTTPS_PROXY
の設定内容)を確認するとよろしいかと思います。