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

The AddMinio method does not add the IMinioClient to DI correctly #1046

Open
Maxaytt opened this issue Apr 4, 2024 · 3 comments
Open

The AddMinio method does not add the IMinioClient to DI correctly #1046

Maxaytt opened this issue Apr 4, 2024 · 3 comments

Comments

@Maxaytt
Copy link

Maxaytt commented Apr 4, 2024

The server does not respond to any actions from the client.

I will describe my actions step by step:

I add minio server to docker compose:
image

further i added minio to di:
image

next step i added simple controller: for testing
image

i writed docker compose up. here are the logs:
image

next i send POST and GET requests to api:

image
image

the response should have been a list from one bucket, but nothing came
UPDATE:

I experimented a little more and realized that DI did not work. Instead of AddMinio, I tried to create a client object manually and everything worked

@Maxaytt Maxaytt changed the title Client unable to interact with minio service in docker compose The AddMinio method does not add the IMinioClient correctly Apr 4, 2024
@Maxaytt Maxaytt changed the title The AddMinio method does not add the IMinioClient correctly The AddMinio method does not add the IMinioClient to DI correctly Apr 5, 2024
@Jamess-Lucass
Copy link
Contributor

+1 I encounter this issue.

Current workaround would be to just new up MinioClient when needed and forget about DI

@Jamess-Lucass
Copy link
Contributor

Jamess-Lucass commented Apr 24, 2024

The root cause is that the factory is creating minio with SSL enabled by default.

Using DI will create the minio client using the factory (https://github.com/minio/minio-dotnet/blob/master/Minio/ServiceCollectionExtensions.cs#L47).

This will create the MinioClient with SSL as defaulted (https://github.com/minio/minio-dotnet/blob/master/Minio/MinioClientFactory.cs#L40).

@Maxaytt If you change your DI registration to the following

builder.Services.AddMinio(configureClient => configureClient
    .WithEndpoint(endpoint)
    .WithCredentials(accessKey, secretKey)
    .WithSSL(false));

Then it should work.

@Soulusions
Copy link

Running into the exact same issue with an identical setup, .NET 8 & DI, with or without WithSSL(false), with or without .Build(), I simply cannot get the minio client to do anything, even more frustrating is that it fails completely silently...

I'm currently trying to access the client using the following:

builder.Services.AddMinio(configureClient  => configureClient 
        .WithEndpoint("localhost", 9000)
        .WithCredentials(
            "realuser",
            "veryrealpassword")
        .WithSSL(false)
        .Build());

Injection fails with both a factory and the standalone client.

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