Python 連線 Minio 報錯:[SSL: WRONG_VERSION_NUMBER]

ponponon發表於2022-06-16
from minio import Minio
from minio.error import S3Error


def main():
    # Create a client with the MinIO server playground, its access key
    # and secret key.
    client = Minio(
        "192.168.31.245:9000",
        access_key="ponponon",
        secret_key="ponponon"
    )

    # Make 'asiatrip' bucket if not exist.
    found = client.bucket_exists("whoisface")
    if not found:
        client.make_bucket("whoisface")
    else:
        print("Bucket 'whoisface' already exists")

    # Upload '/home/user/Photos/asiaphotos.zip' as object name
    # 'asiaphotos-2015.zip' to bucket 'asiatrip'.
    # client.fput_object(
    #     "asiatrip", "asiaphotos-2015.zip", "/home/user/Photos/asiaphotos.zip",
    # )
    # print(
    #     "'/home/user/Photos/asiaphotos.zip' is successfully uploaded as "
    #     "object 'asiaphotos-2015.zip' to bucket 'asiatrip'."
    # )


if __name__ == "__main__":
    main()
    # try:
    #     main()
    # except S3Error as exc:
    #     print("error occurred.", exc)

報錯:

  File "/home/bot/.local/share/virtualenvs/ideaboom-3stdf9Mx/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='192.168.31.245', port=9000): Max retries exceeded with url: /whoisface?location= (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:997)')))

解決辦法:

client = Minio(
    "192.168.31.245:9000",
    access_key="ponponon",
    secret_key="ponponon",
    secure=False
)

加上如果是 http,加上 secure=False

相關文章