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

Windows, network have issue, the DownloadObject ,GetObject response don't have reply #158

Closed Jon118Lexi closed 3 months ago

Jon118Lexi commented 3 months ago

When I use DownloadObject or GetObject to download or retrieve an object, a network issue occurs (e.g., disconnection or no network), and there is no response. There is no exception that can be caught. The code just executes the download/GetObject line, and the rest of the code does not execute.

balamurugana commented 3 months ago

Duplicate of https://github.com/minio/minio-cpp/issues/125

Jon118Lexi commented 3 months ago

Duplicate of #125


int main() {
  // Create S3 base URL.
  minio::s3::BaseUrl base_url("192.168.3.60", false);
  base_url.port= 9000;

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

  // Create S3 client.
  minio::s3::Client client(base_url, &provider);

  // Create get object arguments.
  minio::s3::GetObjectArgs args;
  args.bucket = "test";
  args.object = "gdfg.txt";
  args.datafunc = [](minio::http::DataFunctionArgs args) -> bool {
    std::cout << "received data: " << args.datachunk.length() << " bytes"
              << std::endl;
    return true;
  };
  args.progressfunc = [](minio::http::ProgressFunctionArgs args) -> bool {
    if (args.download_speed > 0) {
      std::cout << "downloaded speed: " << (long)args.download_speed << " bps"
                << std::endl;
    } else {
      std::cout << "downloaded: " << (long)args.downloaded_bytes << " bytes of "
                << (long)args.download_total_bytes << " bytes" << std::endl;
    }
    return true;
  };

  // Call get object.
  client.Debug(true);
  minio::s3::GetObjectResponse resp = client.GetObject(args);

  // Handle response.
  if (resp) {
    std::cout << std::endl
              << "data of my-object is received successfully" << std::endl;
  } else {
    std::cout << "unable to get object; " << resp.Error().String() << std::endl;
  }

  return 0;
}

The debug console:
* \*   Trying 192.168.3.60:9000...*
![debug](https://github.com/user-attachments/assets/1f853b2e-56d9-4780-b891-991d92de4927)