getting an error while connecting mongodb with replicaset-Bitnami - mongodb

I have deployed bitnami MongoDB with replicaset on Azure and I haven't changed anything but when I try to connect MongoDB using connection string then I'm getting an error like `
Connection failed.
SERVER [xyz.southeastasia.cloudapp.azure.com:27017] (Type: UNKNOWN)
|_/ Connection error (MongoSocketReadTimeoutException): Timeout while receiving message
|____/ I/O error: Read timed out
Details:
Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=xyz.southeastasia.cloudapp.azure.com:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadTimeoutException: Timeout while receiving message}, caused by {java.net.SocketTimeoutException: Read timed out}}]
I have running bitnami mongodb with replicaset on azure which was created one month back that time i haven't faced this issue.

It looks to me that the address may have changed. I advise you to confirm that xyz.southeastasia.cloudapp.azure.com still points to the same IP address you want to connect. Also check that there are no firewall rules blocking the traffic.

Related

opsmanager application not able to connect to opsmanager database

I have installed opsmanager database in one instance and application in other instance
Taken points from this link
In application database server when i netstat -nltp it shows 127.0.0.1:27017 running mongod
After installing application in other instance I edit the mongo.mongoUri as mongodb://db_instance_publicip:27017 in /opt/mongodb/mms/conf/conf-mms.properties
When I start by sudo service mongodb-mms start is shows below error
uri=mongodb://db_instance_publicip:27017/?maxPoolSize=150} Error: Timed out after 30000 ms while waiting to connect.......
Error: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=db_instance_publicip:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]
Was facing the same issue. The issue in my case was that my Mongo DB was binding to only localhost thanks to this line in /etc/mongod.conf:
bindIp: 127.0.0.1 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
As the commented part in the same line suggests, I had to replace "127.0.0.1" with "0.0.0.0" and restart Mongo DB and it started working!

Exception while interacting with MongoDB using Java

I am trying to connect to MongoDB 3.6 with Java. When I tried to interact with the database, I received the following exception
Timed out after 30000 ms while waiting for a server that matches WritableServerSelector.
Client view of cluster state is {type=REPLICA_SET, servers=[{address=localhost:27017,
type=REPLICA_SET_GHOST, roundTripTime=0.8 ms, state=CONNECTED}]. Cause: Timed out after 30000
ms while waiting for a server that matches WritableServerSelector.
Why am I getting this error? What does it mean and how to solve this ?

I can't see my data in my mongodb databse

this is the first time I'm using MongoDB and when I connect my MongoDB database by SSH connection to Studio 3T I can see the database and the collection: Hre he is (I'm hosting the website on a server under centos 8)1
The website work, I can signup, signing, logout, etc but I can't see the users in my user's collection : 2
I'm using a source of a website in nodejs and the database already have users etc and I just would like to clear it and to add the rank admin on my user to have access to the admin panel.
I don't understand why those collections are empty.
EDIT : when I try to connect my mongodb database to studio 3t by URI I have this error :
connection failed.
SERVER [45.9.188.221:27017] (Type: UNKNOWN)
|_/ Connection error (MongoSocketOpenException): Exception opening socket
|____/ Socket error: Connection refused: connect
Details:
Timed out after 5000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=45.9.188.221:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]
Help, please

Unable to connect to Mongo Using VertxMongo clinent

Hi enables ssl in mongo server and trying to connect from vertx MongoClient.
Step followed : "ssl":true in configuration and set System.setProperty("org.mongodb.async.type", "netty") before intializing the clinet. When I try running my vertx application i am getting following error. can some one please help?
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=testssl#cv.com:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, caused by {javax.net.ssl.SSLException: SSLEngine closed already}}]
at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:377)
at com.mongodb.connection.BaseCluster.handleServerSelectionRequest(BaseCluster.java:292)
at com.mongodb.connection.BaseCluster.access$800(BaseCluster.java:54)
at com.mongodb.connection.BaseCluster$WaitQueueHandler.run(BaseCluster.java:458)
at java.lang.Thread.run(Thread.java:745)

Grails 3 and Mlab MongoDB

I am trying to connect my simple POC grails app to my Mlab MongoDB database. I am able to connect via the terminal just fine. But my grails app keeps trying to connect to localhost:127.0.0.1:27017. However my connection string in application.yml point to my mlab instance. Any ideas on this?
Here is the stack trace:
ERROR org.springframework.boot.SpringApplication - Application startup failed
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=127.0.0.1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]
Grails 3 has a good support for mongodb. You can connect to mongodb using below configuration in application.yml file.
grails:
mongodb:
url: mongodb://username:password#xxxxxxxx:15340/demoapp
Also make sure you have the below dependency on build.gradle file.
compile 'org.grails.plugins:mongodb:6.1.3'