Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I have an SDK request problem #54

Closed
xiaonaiquan opened this issue Oct 31, 2022 · 4 comments
Closed

I have an SDK request problem #54

xiaonaiquan opened this issue Oct 31, 2022 · 4 comments

Comments

@xiaonaiquan
Copy link

Hi,I have an SDK request problem,I use the following code, return “MakeBucket(): invalid response received; status code: 400; content-type: text/xml; charset=utf-8”,You know why?

code:
minio::s3::MakeBucketArgs args1;
args1.bucket = "test";
minio::s3::MakeBucketResponse resp1 = client.MakeBucket(args1);
if (!resp1)
{
throw std::runtime_error("MakeBucket(): " + resp1.Error().String());
}

@balamurugana
Copy link
Member

Enable client.Debug(true); and check what's going on.

@xiaonaiquan
Copy link
Author

  • STATE: INIT => CONNECT handle 0xaaaaff956fb8; line 1837 (connection #-5000)
  • Added connection 0. The cache now contains 1 members
  • family0 == v4, family1 == v6
  • Trying 10.211.55.4:9090...
  • STATE: CONNECT => CONNECTING handle 0xaaaaff956fb8; line 1898 (connection #0)
  • Connected to 10.211.55.4 (10.211.55.4) port 9090 (#0)
  • STATE: CONNECTING => PROTOCONNECT handle 0xaaaaff956fb8; line 2030 (connection #0)
  • STATE: PROTOCONNECT => DO handle 0xaaaaff956fb8; line 2053 (connection #0)

GET /test?location= HTTP/1.1
Host: 10.211.55.4
Accept: /
Authorization: AWS4-HMAC-SHA256 Credential=minioadmin/20221031/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=11fb521935bc661418b302870bf83b96168a416600119de54768e390c34d215d
User-Agent: MinIO (Linux; aarch64) minio-cpp/0.1.0
x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
x-amz-date: 20221031T042253Z

  • STATE: DO => DID handle 0xaaaaff956fb8; line 2149 (connection #0)
  • STATE: DID => PERFORMING handle 0xaaaaff956fb8; line 2268 (connection #0)
  • Mark bundle as not supporting multiuse
  • HTTP 1.1 or later with persistent connection
    < HTTP/1.1 400 Bad Request
    < Location: http://127.0.0.1:9000
    < Date: Mon, 31 Oct 2022 04:22:53 GMT
    < Content-Length: 165
    < Content-Type: text/xml; charset=utf-8
    < Connection: close
    <
  • STATE: PERFORMING => DONE handle 0xaaaaff956fb8; line 2467 (connection #0)
  • multi_done: status: 0 prem: 0 done: 0
  • The cache now contains 0 members
  • Closing connection 0
  • Expire cleared (transfer 0xaaaaff956fb8)
    test does not exist
  • STATE: INIT => CONNECT handle 0xaaaaff958708; line 1837 (connection #-5000)
  • Added connection 0. The cache now contains 1 members
  • family0 == v4, family1 == v6
  • Trying 10.211.55.4:9090...
  • STATE: CONNECT => CONNECTING handle 0xaaaaff958708; line 1898 (connection #0)
  • Connected to 10.211.55.4 (10.211.55.4) port 9090 (#0)
  • STATE: CONNECTING => PROTOCONNECT handle 0xaaaaff958708; line 2030 (connection #0)
  • STATE: PROTOCONNECT => DO handle 0xaaaaff958708; line 2053 (connection #0)

PUT /test HTTP/1.1
Host: 10.211.55.4
Accept: /
Authorization: AWS4-HMAC-SHA256 Credential=minioadmin/20221031/us-east-1/s3/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-content-sha256;x-amz-date, Signature=dba7272f0307283d3c5772c05fbf2f18fa69e4b1fb9e966f024e77cc8c22b9f5
Content-Length: 0
Content-Type: application/octet-stream
User-Agent: MinIO (Linux; aarch64) minio-cpp/0.1.0
x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
x-amz-date: 20221031T042253Z

  • STATE: DO => DID handle 0xaaaaff958708; line 2149 (connection #0)
  • STATE: DID => PERFORMING handle 0xaaaaff958708; line 2268 (connection #0)
  • Mark bundle as not supporting multiuse
  • HTTP 1.1 or later with persistent connection
    < HTTP/1.1 400 Bad Request
    < Location: http://127.0.0.1:9000
    < Date: Mon, 31 Oct 2022 04:22:53 GMT
    < Content-Length: 165
    < Content-Type: text/xml; charset=utf-8
    < Connection: close
    <
  • STATE: PERFORMING => DONE handle 0xaaaaff958708; line 2467 (connection #0)
  • multi_done: status: 0 prem: 0 done: 0
  • The cache now contains 0 members
  • Closing connection 0
  • Expire cleared (transfer 0xaaaaff958708)
    terminate called after throwing an instance of 'std::runtime_error'
    what(): MakeBucket(): invalid response received; status code: 400; content-type: text/xml; charset=utf-8
    Aborted (core dumped)

@balamurugana
Copy link
Member

Below example works fine. Purely your local issue.

#include "client.h"

int main(int argc, char* argv[]) {
  // Create S3 base URL.
  minio::s3::BaseUrl base_url("localhost:9000", false);

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

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

  // Create make bucket arguments.
  minio::s3::MakeBucketArgs args;
  args.bucket = "my-bucket";

  // Call make bucket.
  minio::s3::MakeBucketResponse resp = client.MakeBucket(args);

  // Handle response.
  if (resp) {
    std::cout << "my-bucket is created successfully" << std::endl;
  } else {
    std::cout << "unable to create bucket; " << resp.Error().String()
              << std::endl;
  }

  return 0;
}
* STATE: INIT => CONNECT handle 0x1fdb5c8; line 1837 (connection #-5000)
* Added connection 0. The cache now contains 1 members
* family0 == v4, family1 == v6
*   Trying 127.0.0.1:9000...
* STATE: CONNECT => CONNECTING handle 0x1fdb5c8; line 1898 (connection #0)
* Connected to localhost (127.0.0.1) port 9000 (#0)
* STATE: CONNECTING => PROTOCONNECT handle 0x1fdb5c8; line 2030 (connection #0)
* STATE: PROTOCONNECT => DO handle 0x1fdb5c8; line 2053 (connection #0)
> PUT /my-bucket HTTP/1.1
Host: localhost
Accept: */*
Authorization: AWS4-HMAC-SHA256 Credential=minioadmin/20221031/us-east-1/s3/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-content-sha256;x-amz-date, Signature=066921d3d9cfa1b6ac47b29b8c882e2aae6cdc87b4403b71ae4cbbefd3d4d4b4
Content-Length: 0
Content-Type: application/octet-stream
User-Agent: MinIO (Linux; x86_64) minio-cpp/0.1.0
x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
x-amz-date: 20221031T045739Z

* STATE: DO => DID handle 0x1fdb5c8; line 2149 (connection #0)
* STATE: DID => PERFORMING handle 0x1fdb5c8; line 2268 (connection #0)
* Mark bundle as not supporting multiuse
* HTTP 1.1 or later with persistent connection
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Length: 0
< Content-Security-Policy: block-all-mixed-content
< Location: /my-bucket
< Server: MinIO
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Vary: Origin
< Vary: Accept-Encoding
< X-Amz-Request-Id: 17230E86DA7234A6
< X-Content-Type-Options: nosniff
< X-Xss-Protection: 1; mode=block
< Date: Mon, 31 Oct 2022 04:57:39 GMT
< 
* STATE: PERFORMING => DONE handle 0x1fdb5c8; line 2467 (connection #0)
* multi_done: status: 0 prem: 0 done: 0
* Connection #0 to host localhost left intact
* Expire cleared (transfer 0x1fdb5c8)
my-bucket is created successfully

@harshavardhana
Copy link
Member

  • < HTTP/1.1 400 Bad Request
    < Location: http://127.0.0.1:9000
    < Date: Mon, 31 Oct 2022 04:22:53 GMT
    < Content-Length: 165
    < Content-Type: text/xml; charset=utf-8
    < Connection: close

Looks like you have a proxy here @xiaonaiquan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants