minio / minio-dotnet

MinIO Client SDK for .NET
https://docs.min.io/docs/dotnet-client-quickstart-guide.html
Apache License 2.0
569 stars 227 forks source link

always get a bad request exception when run the sample test. #56

Closed philxia closed 8 years ago

philxia commented 8 years ago

I setup the minio server and client at 2 windows machines separately, start the minio server at machine-A, and try the mc.exe in another machine-B to connect it with the credential, it works as expected, like list bucket, and upload file. I tried the .net sample test to list bucket or checking if the bucket exist, always got a bad request exception. I checked the console output of minio server and it said - time="2015-11-25T15:58:50+08:00" level=error msg="Unknown region in authorizatio n header." Error={Invalid region *errors.errorString [{81 C:/mygo/src/github.com /minio/minio/api-signature.go main.isValidRegion map[]} {89 C:/mygo/src/github.c om/minio/minio/api-signature.go main.stripAccessKeyID map[]} {108 C:/mygo/src/gi thub.com/minio/minio/api-signature.go main.initSignatureV4 map[]} {84 C:/mygo/sr c/github.com/minio/minio/signature-handler.go main.signatureHandler.ServeHTTP ma p[]}] map[host.os:windows host.arch:amd64 host.name:SHA2UA0151LHQ host.cpus:8 me m.heap.total:3.0MB host.lang:go1.5.1 mem.used:2.2MB mem.total:6.1MB mem.heap.use d:2.2MB]}

Do i miss anything? Thanks in advance.

harshavardhana commented 8 years ago

time="2015-11-25T15:58:50+08:00" level=error msg="Unknown region in authorizatio n header." Error={Invalid region *errors.errorString [{81 C:/mygo/src/github.com /minio/minio/api-signature.go main.isValidRegion map[]} {89 C:/mygo/src/github.c om/minio/minio/api-signature.go main.stripAccessKeyID map[]} {108 C:/mygo/src/gi thub.com/minio/minio/api-signature.go main.initSignatureV4 map[]} {84 C:/mygo/sr c/github.com/minio/minio/signature-handler.go main.signatureHandler.ServeHTTP ma p[]}] map[host.os:windows host.arch:amd64 host.name:SHA2UA0151LHQ host.cpus:8 me m.heap.total:3.0MB host.lang:go1.5.1 mem.used:2.2MB mem.total:6.1MB mem.heap.use d:2.2MB]}

Recently minio server moved its region from default 'milkyway' to 'us-east-1' . Looks like you are using published dotnet package? I haven't published new changes yet which were done to this repo recently.

Can you clone this repo and try again?

harshavardhana commented 8 years ago

I have published an updated nuget package. Can you update and try again?

philxia commented 8 years ago

Thanks for replying. I tried both this repo (sync to head) and nuget pckage (Successfully installed 'Minio 0.2.1' to Test), but still get the same error.

harshavardhana commented 8 years ago

I tried both this repo (sync to head) and nuget pckage (Successfully installed 'Minio 0.2.1' to Test), but still get the same error.

@philxia - here is the snippet of the code that i tried with both master and nuget package with server https://github.com/minio/minio

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Minio;
using Minio.Xml;

namespace Minio.Examples
{
    class ListBuckets
    {
        static int Main(string[] args)
        {
            var client = new MinioClient("http://localhost:9000", "WLGDGYAQYIGI833EV05A", "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF");

            var buckets = client.ListBuckets();
            foreach (Bucket bucket in buckets)
            {
                Console.Out.WriteLine(bucket.Name + " " + bucket.CreationDateDateTime);
            }

            return 0;
        }
    }
}
$ mono Minio.Examples/ListBuckets.exe
newbucket 11/23/2015 5:49:58 AM
testbucket 11/21/2015 5:39:18 PM
harshavardhana commented 8 years ago

Which version of server are you using?

philxia commented 8 years ago

Minio server version is "2015-11-14T09:02:54Z", and I stepped into the code and get the error message as below. Any clue?

AuthorizationHeaderMalformedThe authorization header is malformed; the region is wrong; expecting 'milkyway'./3L1373L137
harshavardhana commented 8 years ago

Minio server version is "2015-11-14T09:02:54Z", and I stepped into the code and get the error message as below. Any clue?

Now i know what the issue is, we recently changed server to use "us-east-1" instead of "milkyway" so the current version of the library is incompatible with the released binaries. Will be building new versions of the server soon.

You should use '0.2.0' version which should work properly. Here is how i tested locally.

$ mkdir newproj
$ cd newproj
$ mono nuget.exe install minio -Version 0.2.0
$ mcs /r:Minio.0.2.0/lib/net45/Minio.dll ListBuckets.cs
$ export MONO_PATH=Minio.0.2.0/lib/net45:RestSharp.105.1.0/lib/net45
$ mono ListBuckets.exe
newbucket 11/23/2015 5:49:58 AM
testbucket 11/21/2015 5:39:18 PM

Let me know if you see the same issue.

philxia commented 8 years ago

Awesome! Works like a charm. Thank you very much.