Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Jean1636577440
Contributor

Failed to connect to MongoDB database

Hello to all, 

 

I'm here to ask for your help because I want to connect to a remote MongoDB database, when I configure my metadata and check the connection to the Mongo database, I get the following error message:

 

------------------------------------------------------------------------------------------------------------------------

Connection failed.

 org.talend.repository.nosql.exceptions.NoSQLServerException: Unable to connect to the database.

   at org.talend.repository.nosql.db.util.mongodb.MongoDBConnectionUtil.checkConnection(MongoDBConnectionUtil.java:86)

   at org.talend.repository.nosql.db.provider.mongodb.MongoDBMetadataProvider.checkConnection(MongoDBMetadataProvider.java:156)

   at org.talend.repository.nosql.ui.common.AbstractNoSQLConnForm$1$1.run(AbstractNoSQLConnForm.java:157)

   at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)

 Caused by: org.talend.repository.nosql.exceptions.NoSQLServerException: org.talend.repository.nosql.exceptions.NoSQLReflectionException: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=remote-base-dev-user-talend:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: remote-base-dev-user-talend}, caused by {java.net.UnknownHostException: remote-base-dev-user-talend}}]

   at org.talend.repository.nosql.db.util.mongodb.MongoDBConnectionUtil.getDatabaseNames(MongoDBConnectionUtil.java:287)

   at org.talend.repository.nosql.db.util.mongodb.MongoDBConnectionUtil.checkConnection(MongoDBConnectionUtil.java:56)

   ... 3 more

 Caused by: org.talend.repository.nosql.exceptions.NoSQLReflectionException: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=remote-base-dev-user-talend:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: remote-base-dev-user-talend}, caused by {java.net.UnknownHostException: remote-base-dev-user-talend}}]

   at org.talend.repository.nosql.reflection.NoSQLReflection$WrapException.wrap(NoSQLReflection.java:97)

   at org.talend.repository.nosql.reflection.NoSQLReflection.invokeMethod(NoSQLReflection.java:68)

   at org.talend.repository.nosql.reflection.NoSQLReflection.invokeMethod(NoSQLReflection.java:53)

   at org.talend.repository.nosql.db.util.mongodb.MongoDBConnectionUtil.getDatabaseNames(MongoDBConnectionUtil.java:282)

   ... 4 more

 Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=messika-clt-dev-user-talend:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: messika-clt-dev-user-talend}, caused by {java.net.UnknownHostException: messika-clt-dev-user-talend}}]

   at com.mongodb.internal.connection.BaseCluster.getDescription(BaseCluster.java:182)

   at com.mongodb.internal.connection.AbstractMultiServerCluster.getDescription(AbstractMultiServerCluster.java:54)

   at com.mongodb.client.internal.MongoClientDelegate.getConnectedClusterDescription(MongoClientDelegate.java:152)

   at com.mongodb.client.internal.MongoClientDelegate.createClientSession(MongoClientDelegate.java:103)

   at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.getClientSession(MongoClientDelegate.java:284)

   at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:188)

   at com.mongodb.client.internal.MongoIterableImpl.execute(MongoIterableImpl.java:143)

   at com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:92)

   at com.mongodb.client.internal.MongoIterableImpl.forEach(MongoIterableImpl.java:121)

   at com.mongodb.client.internal.MappingIterable.forEach(MappingIterable.java:59)

   at com.mongodb.client.internal.MappingIterable.into(MappingIterable.java:69)

   at com.mongodb.Mongo.getDatabaseNames(Mongo.java:495)

   at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

   at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

   at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

   at java.base/java.lang.reflect.Method.invoke(Method.java:566)

   at org.talend.core.utils.ReflectionUtils.invokeMethod(ReflectionUtils.java:167)

   at org.talend.repository.nosql.reflection.NoSQLReflection$3.toDo(NoSQLReflection.java:63)

   at org.talend.repository.nosql.reflection.NoSQLReflection$WrapException.wrap(NoSQLReflection.java:95)

   ... 7 more

 

-------------------------------------------------------------------------------------------------------------------------

 

I have been provided a string connection and a username and password for authentication.

 

I can connect to the database with mongo-compass with this connection string.

I use Talend Open Studio for Big Data 7.3, I found that the connection to Mongo on Talend supports only mongo 3.5, 3.2 ..., the remote database is managed with mongo enterprise version 4, I do not know if this is the problem.

 

I have downloaded and installed all the libraries to run mongo, I did a test by selecting the other versions of mongo and I still have this error message.

 

I thank you in advance for your help and your answers.

Labels (3)
4 Replies
Anonymous
Not applicable

Hello,

We have already upgraded the MongoDb drivers to be able to work with 4.x starting from Talend 7.1.

Are you on Windows and what's java version are you using?

In addition to that, please make sure that you have the correct certificate when you use certificate authority and private key files to connect to MongoDB through Talend Using SSl Connection.

Best regards

Sabrina

 

Jean1636577440
Contributor
Author

Hello,

 

I am using Windows 10, and java 8 is currently installed and The version 3.4.2 of mongo-java-driver is installed 

 

When I create my connection metadata I don't have an SSL option to specify.

 

How can I check if I have the right SSL certificate? 

Jean1636577440
Contributor
Author

So I have performed a test with a task that only reads data from the MongoDB database, the connection works and I can retrieve the data successfully.

 

In the tMongoDBConnection component, I performed a test with a task that only reads data from the MongoDB database. The connection works and I can retrieve the data successfully.

In the tMongoDBConnection component I made the following changes:

 

- Add replica sets

- I added "admin" in the authentication database

- I have enabled the SSL option

- Username and password for authentication

 

So I can't create a NoSQL connection metadata, the connection test fails and I can't retrieve the schemas for this metadata.

 

Maybe some options needed for my connection are missing in the popup, and I can't create a Mongo metadata.

 

Anonymous
Not applicable

Hello,

Here is a KB article about: https://community.talend.com/s/article/Cannot-connect-to-Mongo-Atlas-DB

Please notice that the cluster name is case sensitive with the Java driver for MongoDB.

Here is a link to the relevant Jira ticket with MongoDB.

https://jira.mongodb.org/browse/JAVA-2569

Best regards

Sabrina