Problem in connecting to Mongodb Atlas

Hello

I am trying to connect to Mongodb database in Atlas. I am getting the error

ERROR MongoDB Reader 0:1 Execute failed: Timed out after 10000 ms while waiting to connect. Client view of cluster state is {type=Unknown, servers=[{address:27017=yqy1b.mongodb.net, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket}, caused by {java.net.UnknownHostException: yqy1b.mongodb.net}}]

The link for the connection is mongodb+srv://username:password@cluster0.yqy1b.mongodb.net/db_name?authSource=admin
I entered the data as:
Host: cluster0.yqy1b.mongodb.net
Port: 27017
Database: db_name
Authentication Database : admin
I specified the collection I need in the field collection too
Username and password are obvious.
I don’t get what I did wrong here? Is there any solution to my problem?

1 Like

Hi,
I think in this case the problem is not MongoDB, but that your computer cannot even connect to that server. UnknownHostException means that your computer tries to get the IP address for cluster0.yqy1b.mongodb.net but the DNS server cannot resolve it. Maybe you need to use a proxy or have a typo in the host name?
Kind regards,
Alexander

@AlexanderFillbrunn, I had a look at this too and having created a mongodb atlas database hit the same issue.

As well as java complaining, I cannot even ping mongodb.net as that gives me an unreachable error (or might be a unknown host error… Can’t remember and I’m not at the pc today). Could be it’s set to not respond to ping but the message indicated that ping wasn’t even getting that far

I tried changing my dns to something other than my isp supplied one (opendns, I think) but with no improvement. I did wonder if other people are actually able to ping mongodb.net directly. It seems very strange. I’ve seen other people reporting similar on stackoverflow.

You are right that java reporting host unreachable does indicate connectivity or dns issue.

Oddly, I can reach the database via the mongodb shell installed on my pc, and through the mongodb compass application, so the connectivity is clearly there, but not for ping or java…

2 Likes

Hi,
a revised version of the MongoDB nodes will be published with the upcoming 4.4 release. This includes support for MongoDB Atlas. If you want to give it a try download the nightly build from here. Once you have installed the MongoDB extension you will find the new MongoDB Connector node where you have to use SRV as connection type as shown below:


When entering the hostname remove the port since this is not required for SRV.
Let us know if this works for you.
Bye
Tobias

6 Likes

Hi there,
I am somewhat new to KNIME and have been trying to connect different data sources within KNIME.
That worked quite well, but I am struggling with MongoDB so far.

I am using the “MongoDB connector” as we can see above, using an hostname provided by my tech team (something starting with heroku-(figure and letters)). That seems to connect and that heroku-() would be the name of the database.
Then I am using the node “MongoDB reader” but I can not select collection. When I try to fetch the metadata, I am getting an error which starts with:

“Error during fetching metadata from the database: com.mongodb.MongoCommandException: Command failed with error 13 (Unauthorized): 'not authorized on config to execute command { listCollections: 1, cursor: {}, nameOnly: true, $db: “config”, $clusterTime:…”

Seems I am trying to read the database “config”, instead of the heroku-(), which clearly does not have any collection.
Knime version is KNIME 4.7.1

@tobias.koetter, have you seen sthg similar already?
Happy to provide more details to help structuring my question.

Bertrand

Hi everyone,
If I am not providing enough information to answer the question, please let me know, I am happy to give more.
@AlexanderFillbrunn, would it be something you have seen in the past too?
Best,
Bertrand

Hi Bertrand,
I am not sure where the “config” is coming from, but it might also be a username. Maybe your IT team has also not enabled the option to lost collections for your user? If you know the collection name, can you enter it together with the right database name manually in the corresponding text fields and try to execute the read?
Kind regards,
Alexander

1 Like

Hi @AlexanderFillbrunn,

Thanks a lot for answering, much appreciated.
Basically for the MongoDB Connector node I am using:
Type: SRV
Hostname: heroku-xxxx.yyyy.mongodb.net
Port: nothing

Username & password were given to me by the IT team
Authentification database: admin (given too)

And on the MongoDB reader
Database: heroku-xxxx
Collection: I have been given the name of a collection “garages” which is what I am using

When I try to fetch, I am getting the error message above and if I run the node, I am getting the following message: “Node created an empty data table”

Something I am not doing right?
Bertrand

Hi,
That does not sound too bad. Maybe the collection is empty or simply does not exist. What do you get when you enter some random name for the collection and then run the node? Does it also produce an empty table or does it give an error complaining that the collection does not exist?
Kind regards,
Alexander

Hi,
I am trying very random names for collection and I am getting “node created an empty data table” each time.
Best
Bertrand

Hi,
Okay, that means that probably the collection does not exist then. Let’s narrow this down further: what if you provide wrong credentials and a random collection? Do you get an authorization error, or does it let you pass and return an empty table?
Kind regards,
Alexander

Hi,
Should we pass the conversation as private messages and explain once we have the solution? (I don’t mind any option).
I tried a wrong “Username” and I am getting the message “Execute failerd: Exception authenticating MongoCredential…”

I tried a wrong Database in the node Reader and getting “empty table” as well

Bertrand

Hi,
For me it is ok to continue here. Not sure if I can provide much more help, though. I assume that MongoDB just treats a non-existing collection like an empty collection. If the authorization succeeds, that tells us that the connection can be established properly. Can you try another client, like Compass if you can read the correct data there?
Kind regards,
Alexander

Hi,
Let me check with Compass and my team and I come back to you.
Thanks again for the help today in any case
Bertrand

Hi @AlexanderFillbrunn,
I have tried with Compass and indeed I can see all the database and all the collections there (using the same credentials as before).
Collections do exist then (that’s a good news already)
Bertrand

Hi Bertrand,
I just created an account for MongoDB Atlas and created a fresh database. I also could enter any collection and would get an empty table back, but when I used the MongoDB Writer to first write into the collection and then the Reader again, I could read what I had just written. So in theory this should work fine. Do you see data in the “garage” collection via Compass as well? I am not sure what else we could check :-/
Kind regards,
Alexander

1 Like

Hi Alexander,
I can indeed see data in the collection “garage” through Compass.
Actually I can see data of every collection.

That looks weird, you could only read what you wrote yourself with a node?
I don’t think I am using MongoDB/Knime is a unusual way.

Bertrand

Hi Bertrand,
No, I agree, you should not only see what you wrote. I just wanted to test if the reading works at all. I will inform our developers about this thread. Maybe they have an idea.
Kind regards,
Alexander

Hi Alexander,
Great, thanks a lot !
Hopefully they have some suggestions indeed. Looking forward to hearing from you soon then !
Kind regards,
Bertrand

Hi Bertrand,
Unfortunately we cannot reproduce this issue internally. We tried reading from a collection where we previously wrote data with another tool and it worked just fine. Can you read data that you have written with KNIME before?
Kind regards,
Alexander

PS: we are using MongoDB driver version 4.2.3, in case that helps you with your investigation.

1 Like