Quentin Herzig
Quentin Herzig

Reputation: 113

Can't connect to mongodb service

I created a mongodb service and then a Service Key to access the database, but I can't connect. Here's the response I got trying with Studio 3T:

Connection failed.

SERVER [kubernetes-service-node.service.consul:XXX] (Type: UNKNOWN) 
|_/ Connection error (MongoSocketOpenException): Exception opening socket
|____/ Unknown host: kubernetes-service-node.service.consul

SERVER [kubernetes-service-node.service.consul:XXX] (Type: UNKNOWN) 
|_/ Connection error (MongoSocketOpenException): Exception opening socket
|____/ Unknown host: kubernetes-service-node.service.consul

SERVER [kubernetes-service-node.service.consul:XXX] (Type: UNKNOWN) 
|_/ Connection error (MongoSocketOpenException): Exception opening socket
|____/ Unknown host: kubernetes-service-node.service.consul

Details:
Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=kubernetes-service-node.service.consul:XXX, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.UnknownHostException: kubernetes-service-node.service.consul}}, {address=kubernetes-service-node.service.consul:XXX, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.UnknownHostException: kubernetes-service-node.service.consul}}, {address=kubernetes-service-node.service.consul:XXX, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.UnknownHostException: kubernetes-service-node.service.consul}}]

How am I supposed to connect ? Am I missing something ?

Upvotes: 0

Views: 1896

Answers (1)

Sandro Mathys
Sandro Mathys

Reputation: 474

The services are not exposed to the internet. The apps can connect after they were bound to the service. If you need to connect to a service from outside (i.e. over the internet), you need to open an ssh tunnel with cf ssh. For more details, consult the following guide: https://docs.developer.swisscom.com/devguide/deploy-apps/ssh-services.html

Upvotes: 1

Related Questions