minio / minio-cpp

MinIO C++ Client SDK for Amazon S3 Compatible Cloud Storage
https://minio-cpp.min.io/
Apache License 2.0
135 stars 56 forks source link

Cannot connect to the minio server from another node. #144

Closed mivenHan closed 4 months ago

mivenHan commented 5 months ago

I start a minio server in a node with IP 10.2.64.81.

The output is that: `$ docker run --net=host quay.io/minio/minio server /data --console-address ":9001" Formatting 1st pool, 1 set(s), 1 drives per set. WARNING: Host local has more than 0 drives of set. A host failure will result in data becoming unavailable. MinIO Object Storage Server Copyright: 2015-2024 MinIO, Inc. License: GNU AGPLv3 - https://www.gnu.org/licenses/agpl-3.0.html Version: RELEASE.2024-06-06T09-36-42Z (go1.22.4 linux/amd64)

API: http://10.2.64.81:9000 http://172.17.0.1:9000 http://172.18.0.1:9000 http://192.168.122.1:9000 http://127.0.0.1:9000 WebUI: http://10.2.64.81:9001 http://172.17.0.1:9001 http://172.18.0.1:9001 http://192.168.122.1:9001 http://127.0.0.1:9001

Docs: https://min.io/docs/minio/linux/index.html Status: 1 Online, 0 Offline. STARTUP WARNINGS:

I modify the example code for examples/ListBuckets.cc.

` // Create S3 base URL. minio::s3::BaseUrl base_url("https://10.2.64.81:9000");

// Create credential provider. minio::creds::StaticProvider provider( "minioadmin", "minioadmin"); `

The output is always HTTP Error. unable to list buckets; server failed with HTTP status code 0

However, I could use the mc comand to make the buckets and upload the objects. `

mc admin info myminio

● 10.2.64.81:9000 Uptime: 3 hours Version: 2024-06-06T09:36:42Z Network: 1/1 OK Drives: 1/1 OK Pool: 1

┌──────┬────────────────────────┬─────────────────────┬──────────────┐ │ Pool │ Drives Usage │ Erasure stripe size │ Erasure sets │ │ 1st │ 99.0% (total: 834 GiB) │ 1 │ 1 │ └──────┴────────────────────────┴─────────────────────┴──────────────┘

512 MiB Used, 1 Bucket, 1 Object 1 drive online, 0 drives offline, EC:0 `

So, what's wrong with the code? The mc comand could get the right result, but the c++ could not connect the minio server from another node.

mivenHan commented 5 months ago

I add one line code "client.Debug(true);"

The output is below.

root@a40-02:~/minio-cpp# build/ListBuckets
* !!! WARNING !!!
* This is a debug build of libcurl, do not use in production.
* STATE: INIT => SETUP handle 0x556c7910f638; line 1971
* STATE: SETUP => CONNECT handle 0x556c7910f638; line 1987
* Added connection 0. The cache now contains 1 members
* STATE: CONNECT => CONNECTING handle 0x556c7910f638; line 2023
*   Trying 10.2.64.81:9000...
* Connected to 10.2.64.81 (10.2.64.81) port 9000
* Didn't find Session ID in cache for host https://10.2.64.81:9000
* ALPN: curl offers http/1.1
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* OpenSSL/3.3.0: error:0A0000C6:SSL routines::packet length too long
* multi_done[CONNECTING]: status: 35 prem: 1 done: 0
* multi_done, not reusing connection=0, forbid=0, close=0, premature=1, conn_multiplex=0
* The cache now contains 0 members
* Curl_disconnect(conn #0, dead=1)
* Closing connection
unable to list buckets; server failed with HTTP status code 0
mivenHan commented 5 months ago

I also test for the minio-py, it meets the same problem for SSL.

root@a40-02:~/minio-py# python examples/list_buckets.py
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/opt/conda/lib/python3.8/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/opt/conda/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/opt/conda/lib/python3.8/site-packages/urllib3/connection.py", line 414, in connect
    self.sock = ssl_wrap_socket(
  File "/opt/conda/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 453, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File "/opt/conda/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 495, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock)
  File "/opt/conda/lib/python3.8/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/opt/conda/lib/python3.8/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/opt/conda/lib/python3.8/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1131)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "examples/list_buckets.py", line 25, in <module>
    buckets = client.list_buckets()
  File "/opt/conda/lib/python3.8/site-packages/minio-7.2.8-py3.8.egg/minio/api.py", line 677, in list_buckets
  File "/opt/conda/lib/python3.8/site-packages/minio-7.2.8-py3.8.egg/minio/api.py", line 440, in _execute
  File "/opt/conda/lib/python3.8/site-packages/minio-7.2.8-py3.8.egg/minio/api.py", line 302, in _url_open
  File "/opt/conda/lib/python3.8/site-packages/urllib3/poolmanager.py", line 376, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/opt/conda/lib/python3.8/site-packages/urllib3/connectionpool.py", line 815, in urlopen
    return self.urlopen(
  File "/opt/conda/lib/python3.8/site-packages/urllib3/connectionpool.py", line 815, in urlopen
    return self.urlopen(
  File "/opt/conda/lib/python3.8/site-packages/urllib3/connectionpool.py", line 815, in urlopen
    return self.urlopen(
  [Previous line repeated 2 more times]
  File "/opt/conda/lib/python3.8/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/opt/conda/lib/python3.8/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='10.2.64.81', port=9000): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1131)')))
balamurugana commented 4 months ago

@mivenHan You are connecting HTTP as HTTPS or vise versa. Please check you endpoint.

mivenHan commented 4 months ago

I change the IP to minio::s3::BaseUrl base_url("http://10.2.64.81:9000/"); minio::s3::BaseUrl base_url("10.2.64.81:9000/");

Still the same error.

mivenHan commented 4 months ago

@balamurugana

balamurugana commented 4 months ago

If you don't give a secure flag, the default is true. If you are not able to access the minio docker instance, consult your docker provider. Nothing can be done at client side