Question

Cannot access mongodb

  • 25 April 2023
  • 1 reply
  • 21 views

Hi experts,

 

I try to connect Datacollector 5.4 to a MogoDB 4.2 Oplog. I installed the mongo stage libs via the UI, all good. I run dc in a docker host. Mongo runs on the same machine but on the host directly.

I can connect using the follwoing command issued directly from the machine:

mongo --tls --tlsAllowInvalidHostnames --tlsAllowInvalidCertificates 172.17.0.1:27017/edge

Mongo binds to all ips on the machine. 172.17.0.1 is the docker0 interface.

I tested the same command from some other container within the docker host. Hence I assume the network connection is working.

I configured dc similar

 

 

But I  always get this error:

 

CONTAINER_0701 - Stage 'MongoDBOplog_1' initialization error: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=ReadPreference{name=secondaryPreferred}}. Client view of cluster state is {type=UNKNOWN, servers=[{address=172.17.0.1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.NoRouteToHostException: No route to host (Host unreachable)}}]

 

Any ideas?

 

Thanks,

 

Marco


1 reply

Userlevel 4
Badge

Hello @mstoffel - Thank you for reaching out the StreamSets Community.

I had similar issue with Mysql database where data collector is installed as docker container and the database service is running on my mac machine, to resolve this I just replaced the IP to host.docker.internal in the connection string.

If this does not work, please run following command from docker host:

 

  • telnet ip:port
  • ping ip
  • ping 127.0.01

Thank you,

Akshay Jadhav

Reply