.NET C# Application using S3 SDK throws "A WebException with status NameResolutionFailure was thrown"

Hi,
Totally new to Storj Network and I’m attempting a POC with an existing C# application running on .NET Framework 4.7.2.

I’m running the ST S3 Gateway locally and I started out with the aws cli to make sure that works, which it did. It was able to upload a file to my bucket in Storj.

Now I’m trying to do the same thing from code using v3 of the AWS SDK.

Using the same credentials as the cli and the same endpoint, I can list buckets from the Storj account successfully, but I can’t upload a file. The error is:

A WebException with status NameResolutionFailure was thrown.
The remote name could not be resolved: ‘mybucket.localhost’

(I removed the real bucket name and replaced it with mybucket)

The same bucket works with the aws cli, but I don’t have any insight into how the bucket is being resolved there. Is there a way of getting verbose logging on the Gateway? I tried some of the debug logging flags but I didn’t get any extra output on the console.

This is the code for a basic upload test to see if it can create a file:

var putRequest1 = new PutObjectRequest
                {
                    BucketName = bucketName,
                    Key = "sample.txt",
                    ContentBody = "sample text"
                };

                PutObjectResponse response1 = await s3Client.PutObjectAsync(putRequest1);

Any insight would be appreciated!

Hi @deg ,

Welcome to the Forum!
I’ve forwarded your question internally and someone will return with assistance.

2 Likes

This is not a gateway error, this is a dns error. A quick fix for your POC would be to configure the SDK to use path-style requests instead of virtual-hosted style Virtual hosting of buckets - Amazon Simple Storage Service. Another option would be to manually add a record for each bucket to your hosts file.

In production virtual-hosted style buckets are handled by full-featured DNS servers with wildcard syntax.

4 Likes

Thank you! This worked.

2 Likes