#MongoSocketException #JaversBuildException [closed] - mongodb

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Getting the below error while building the project on Jenkins,
Same is getting build on local environment.
MongoSocketException
JaversFromStarter Bean not getting created
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 41.849 s <<< FAILURE! - in in.evergreenrevolution.egr.EgrApplicationTests
[ERROR] contextLoads(in.evergreenrevolution.egr.EgrApplicationTests) Time elapsed: 0.001 s <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'JaversFromStarter' defined in class path resource [org/javers/spring/boot/mongo/JaversMongoAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.javers.core.Javers]: Factory method 'javers' threw exception; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.javers.core.Javers]: Factory method 'javers' threw exception; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]
Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]

Install Mongo DB Server on your local machine or VM
MongoDB Installation

Your build environment is point to localhost, most likely you do not (and do not want to have) MongoDB installed on the build server. Just change you config and point to your mongod.

Related

Connecting to MongoDB / Atlas from pyspark (DataProc) is getting Error

Getting the Below error when trying to connect to mongodb via PySpark(Google DATAPROC), its happening both locally and in Dataproc in GCP. We’re getting the below errors:
py4j.protocol.Py4JJavaError: An error occurred while calling o68.load.
: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while
waiting to connect. Client view of cluster state is {type=UNKNOWN,
servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING,
exception={com.mongodb.MongoSocketOpenException: Exception opening
socket}, caused by {java.net.ConnectException: Connection refused
(Connection refused)}}]
org.mongodb.driver.cluster: Exception in monitor thread while
connecting to server localhost:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
I’ve been using the below command to submit jobs to dataproc. But we’re not sure where the problem is.
gcloud dataproc jobs submit pyspark gs://initmatch/dataproc/files/mongo_spark.py
--cluster=custom-cluster-no-address --region=us-west1 --jars=gs://initmatch/dataproc/jars/mongo-spark-connector-10.0.5.jar,
gs://initmatch/dataproc/jars/mongodb-driver-core-4.8.1.jar,
gs://initmatch/dataproc/jars/mongodb-driver-sync-4.8.1.jar

Mongo time out error when trying to read data using connection uri

This is my connection URI
"mongodb+srv://myUserName:myPassWord#myHost/myDb?retryWrites=true&w=majority"
My user has readAnyDatabase role. But when I try to find a document I get this error.
Error printing return value (MongoTimeoutException) at com.mongodb.internal.connection.BaseCluster/createTimeoutException (BaseCluster.java:401).
Timed out after 30000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate$1#63d3bb68. Client view of cluster state is {type=REPLICA_SET,
servers=[{address=myDb-shard-00-00.qwert.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: Connect timed out}},
{address=myDb-shard-00-02.qwert.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: Connect timed out}},
{address=myDb-shard-00-01.qwert.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: Connect timed out}}]
If you see it's able to connect to the Mongo DB (I am infering this from the fact that it is able to discover all the nodes from myDb-shard-00-00 to myDb-shard-00-02), but gives this error when trying to read some data.
I have connected to other mongo dbs (different uri) with the same code and successfully read documents. So, I am guessing that there should be something wrong with my configuration? Or is it something else? What is the direction that I should be looking at to debug this?

Issue while connecting Mongo Atlas with Spring boot (I tried all stackoverflow solutions already)

I created a test DB in Mongo Atlas.
Below is the uri that I am using in the application properties of the spring boot project.
spring.data.mongodb.uri=mongodb+srv://user:pwd#cluster.mongodb.net/test?retryWrites=true&w=majority&ssl=true&sslInvalidHostNameAllowed=true
I tried this one as well.
spring.data.mongodb.uri=mongodb+srv://user:pwd#cluster.mongodb.net/test?retryWrites=true&w=majority
I have whitelisted my IP in the Atlas
My password contains only the alphanumeric character, no special character.
Still, I get the below exception.
Caused by: org.springframework.dao.DataAccessResourceFailureException: Timed out after
30000 ms while waiting for a server that matches com.mongodb.Mongo$4#707865bd. Client
view of cluster state is {type=REPLICA_SET, servers=[{address=cluster1-shard-00-
01.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception=
{com.mongodb.MongoSocketWriteException: Exception sending message}, caused by
{javax.net.ssl.SSLHandshakeException: extension (5) should not be presented in
certificate_request}}, {address=cluster1-shard-00-02.mongodb.net:27017,
type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException:
Exception sending message}, caused by {javax.net.ssl.SSLHandshakeException: extension
(5) should not be presented in certificate_request}}, {address=cluster1-shard-00-
00.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception=
{com.mongodb.MongoSocketWriteException: Exception sending message}, caused by
{javax.net.ssl.SSLHandshakeException: extension (5) should not be presented in
certificate_request}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out
after 30000 ms while waiting for a server that matches com.mongodb.Mongo$4#707865bd.
Client view of cluster state is {type=REPLICA_SET, servers=[{address=cluster1-shard-00-
01.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception=
{com.mongodb.MongoSocketWriteException: Exception sending message}, caused by
{javax.net.ssl.SSLHandshakeException: extension (5) should not be presented in
certificate_request}}, {address=cluster1-shard-00-02.mongodb.net:27017,
type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException:
Exception sending message}, caused by {javax.net.ssl.SSLHandshakeException: extension (5)
should not be presented in certificate_request}}, {address=cluster1-shard-00-
00.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception=
{com.mongodb.MongoSocketWriteException: Exception sending message}, caused by
{javax.net.ssl.SSLHandshakeException: extension (5) should not be presented in
certificate_request}}]

Kubernetes pod connection to MongoDB Atlas issues

I have two pods in my Kubernetes cluster - one is connecting just fine to my MongoDB Atlas cluster, the other is failing due to the following exception:
Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector.
Client view of cluster state is {type=REPLICA_SET, servers=[{address=MY_MONGO_SERVER1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}, {address=MY_MONGO_SERVER2:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}, {address=MY_MONGO_SERVER3:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}]
Now I'm not sure why one pod is able to connect, while the second one fails. We have another environment (production) that has similar configuration and all is fine with that environment's pods. Also, that environment runs on same Atlas cluster-sized DB, with similarly configured Kubernetes deployments.

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)