Hi there, I’ve been trying to connect to couchbase server, which deployed in my docker container with randomly generated ports (I cannot change that). The problem is, when I try to get all buckets SDK crashes with timeout exception. My theory was that sdk connect to cluster with one port, that I write in connection string (it’s 8091 exposed to 32969, for example), and receives other communication ports from server. In that case received ports are default, because couchbase don’t know about docker ports. I tried to resolve this with port forwarding, but it didn’t help. Also I found that I can tell to couchbase server which alternative ports to use with static_config file, but the problem is, ports generated randomly and I can’t add them to static_config during runtime. Also I tried to set alternate address with couchbase-cli setting-alternate-address command but it doesn`t work either. Am I missing something? Docker running on local machine and there is no other networks.
The simplest solution is to map the ports in docker to the same ports.
btw - the sdk tries to get the config from the the kv port (11210/11207) first. If that fails, then it falls back to the admin port (8091/18901). The second number is for ssl if you are using that.
I cannot change port mapping, unfortunately (it’s part of our test system). But thank you for your answer! Trying to connect to kv port with admin credentials works well, but throws HTTP 401 Unauthorized when trying to do the same with read-only permissions. Is there better solution for read-only users? Or perhaps is there some possibility to configure all this ports directly in SDK?
Hi @fasol . If you can’t make the port mapping static, that does seem challenging to work with… Could you run your application also inside Docker, on the same Docker network as the cluster? I’m not a Docker expert but presumably you’d then be able to connect to the regular ports (11210 etc.) without having to worry about mapping them externally?
Hello. I understand that within docker that works exactly as you described, but I need access to that container externally, and I cannot change that (again, unfortunately). So I am looking for a way to change this port for couchbase server itself, if that possible
I see - I think https://docs.couchbase.com/server/current/install/install-ports.html#map-custom-ports will help. Though getting this working with randomly generated ports sounds challenging.
Hmm… the kv port is not http, so connecting to it will not result in HTTP 401. Other ports (query, admin) are http, so it sounds like you have the port-mapping crossed.
Have you tried configuring Couchbase Server to advertise alternate addresses, so that for example it tells the client to connect to the manager service on port 32969 instead of 8091? If not, that’s a potential solution.
@david.nault but would that not require also exposing a fixed mapping of port 32969 via e.g.
docker run -p 32969:32969? Such fixed mapping does not seem permitted here.