Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongodb connect issue #2383

Closed
nilava opened this issue Aug 6, 2020 · 14 comments · Fixed by #2496
Closed

Mongodb connect issue #2383

nilava opened this issue Aug 6, 2020 · 14 comments · Fixed by #2496
Assignees

Comments

@nilava
Copy link

nilava commented Aug 6, 2020

Short description

Cant connect to mongodb replica set on cloud atlas

https://cloud.mongodb.com/

Environment

  • Ubuntu 18.04 & Latest Enterprise Edition

Logs

Place logs on pastebin or elsewhere and put links here

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcat.cluster' defined in class path resource [jee-container.xml]: Cannot create inner bean 'io.antmedia.enterprise.cluster.ClusterStore#6cf0e0ba' of type [io.antmedia.enterprise.cluster.ClusterStore] while setting bean property 'clusterStore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'io.antmedia.enterprise.cluster.ClusterStore#6cf0e0ba' defined in class path resource [jee-container.xml]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.antmedia.enterprise.cluster.ClusterStore]: Constructor threw exception; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers=[{address=ant-media.1dy4f.azure.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: ant-media.1dy4f.azure.mongodb.net: No address associated with hostname}, caused by {java.net.UnknownHostException: ant-media.1dy4f.azure.mongodb.net: No address associated with hostname}}]

@mekya
Copy link
Contributor

mekya commented Aug 6, 2020

Thank you for the report.

It the log it says something

java.net.UnknownHostException for ant-media.1dy4f.azure.mongodb.net

There may be a kind of DNS issue?

@nilava
Copy link
Author

nilava commented Aug 6, 2020

thats what i initially though, however looks like it cant connect to replica set

using this standalone code works, should i modify the db connect file and build one from source? or is there something i am doing wrong?

MongoClientURI uri = new MongoClientURI(
    "mongodb+srv://admin:<password>@ant-media.1dy4f.azure.mongodb.net/<dbname>?retryWrites=true&w=majority");

MongoClient mongoClient = new MongoClient(uri);
MongoDatabase database = mongoClient.getDatabase("test");

@mekya
Copy link
Contributor

mekya commented Aug 7, 2020

Thank you. I try to check it out at weekend.

@mekya
Copy link
Contributor

mekya commented Aug 9, 2020

My colleague(@muratugureminoglu ) will look into this.

Before that, I should mention that in order to connect to replicaSet. db.host url should be set to something like this.

db.host=<mongo_host>:27017/?replicaSet=<replication_name>

@nilava
Copy link
Author

nilava commented Aug 12, 2020

Tried everything with no success.

@mekya
Copy link
Contributor

mekya commented Aug 17, 2020

Hi @muratugureminoglu ,
Do you have some chance for trying that?

@burak-58
Copy link
Contributor

Hi @nilava,
Could you please try it again after changing change_server_mode.sh file with this one.

@nilava
Copy link
Author

nilava commented Aug 24, 2020

Sure, will try it out, right now we have moved to production use with local mongo db instance with no replica set.
Will spin up a new test instance and test it out.

@choxnox
Copy link

choxnox commented Sep 16, 2020

I'm facing similar issues when trying to run the EE in cluster mode and when Mongo is hosted at Mongo Atlas. I've also tried the suggested change_server_mode.sh script but to no avail.

Screen Shot 2020-09-16 at 11 17 47

It works just fine when I spin up MongoDB instance in DigitalOcean but when I try to use Mongo Atlas service, it simply fails. I've tried with the following:

  • cluster0.xxxxx.mongodb.net
  • cluster0-shard-00-00.xxxxx.mongodb.net:27017,cluster0-shard-00-01.xxxxx.mongodb.net:27017,cluster0-shard-00-02.xxxxx.mongodb.net:27017/replicaSet=atlas-yyyyyy-shard-0
  • cluster0-shard-00-01.xxxxx.mongodb.net

I'm able to connect to the Mongo Atlas cluster with any of the above URIs using MongoDB Compass app or any other Mongo management app.

@choxnox
Copy link

choxnox commented Sep 17, 2020

@mekya Any inputs on this?

@mekya
Copy link
Contributor

mekya commented Sep 21, 2020

Re-opening issue and it'll be scheduled again in this week.

@mekya mekya reopened this Sep 21, 2020
@burak-58
Copy link
Contributor

For MongoDB Atlas, the following works for me:
./change_server_mode.sh cluster 'mymongotestcluster-shard-00-00.xxxxx.mongodb.net:27017/?ssl=true&replicaSet=atlas-yyyyyy-shard-0' user pass

@choxnox
Copy link

choxnox commented Oct 19, 2020

For MongoDB Atlas, the following works for me:
./change_server_mode.sh cluster 'mymongotestcluster-shard-00-00.xxxxx.mongodb.net:27017/?ssl=true&replicaSet=atlas-yyyyyy-shard-0' user pass

This is what I get when I execute that for my Mongo Atlas cluster (v2.1 EE):

Screen Shot 2020-10-19 at 18 57 26

@choxnox
Copy link

choxnox commented Oct 21, 2020

However, this seems to work:

./change_server_mode.sh cluster 'mymongotestcluster-shard-00-00.xxxxx.mongodb.net:27017\/?ssl=true\&replicaSet=atlas-yyyyyy-shard-0' user pass

Notice the "escaped" slash (/) and ampersand (&) characters.

@mekya mekya closed this as completed Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants