.NET Client: Is there way to NOT use port when using cluster.OpenBucket()?

I’ve successfully hosted my docker container in the cloud and via a browser I can hit http://servername.cloud.com/pools. Internally, the cloud service maps to port 8091 and it does exactly what I expect it to do. The problem is, the .NET Client SDK seems to always append :8091 to the URL no matter what I try which fails. The question is, how can I force the Client to NOT add :8091?

Here’s my code:

           var cluster = new Cluster(
                new ClientConfiguration
                {
                    Servers = new List<Uri> { new Uri("http://servername.cloud.com/pools") },
                    Serializer = () =>
                    {
                        var serializerSettings = new JsonSerializerSettings();
                        serializerSettings.ContractResolver = new DefaultContractResolver();
                        return new Couchbase.Core.Serialization.DefaultSerializer(serializerSettings, serializerSettings);
                    }
                }
            );

            var authenticator = new PasswordAuthenticator(username, password);
            cluster.Authenticate(authenticator);

            try
            {
                var bucket = cluster.OpenBucket("BucketName");
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex);
            }

Hi @Livn_Large. Nice handle! :slight_smile:

As of last week, that code maps to the older 2.x SDK. You may want to try the 3.0 SDK if you’re developing new code.

Regarding the URI, it’s probably adding port 8091 because with HTTP and /pools it’s really there for older compatibility. If using docker, you’ll want to map that to port 8091 and map the other ports as covered in the docs. Technically speaking, the SDK will try to do its bootstrap over port 11210. We did it this way to be compatible with existing code, which is a bit of a long story.

In any case, follow the directions there, and you should be good.

Thx for the compliment and quick reply @ingenthr!

I’ll give the new SDK a shot.

I setup the docker container exactly as that article suggested but to clarify, the cloud provider’s web app service only exposes port 80 and 443. Internally as part of their system, I’m able to set the environment variable PORT to 8091. With that variable set, I can successfully access the server with just the base url. Appending the port to the end of that url fails with a timeout. If possible, I’d like to force the SDK to use the base url without attaching a port at all. Is that possible?

The reason why I think it’s adding port 8091 is because while troubleshooting, I set the URL to a fake address http://servername.cloud.com to see what would happen, and it threw the exception: “Couchbase.Utils.UnsupportedAddressFamilyException: http://servername.cloud.com:8091/pools”. Based on that exception, it seems like the SDK added :8091/pools to the end of the URL.

Now, if I use my real url in the SDK, I get a timeout exception which is exactly what happens if I append the port to the end of the base url via a web browser. If I then remove that port via the web browser, success.

I hope that further claries the issue.