com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128) ~[mongodb-driver-core-3.2.2.jar:na]
at java.lang.Thread.run(Thread.java:745)
Are there any other messages in the surrounding log lines? The lines you've included from this stack trace don't have any useful information about why the Mongo client couldn't open the socket.
Looking at this StackOverflow thread, there's sometimes a nested stack trace below the "Thread.run" line that includes a message like "Connection refused". This might indicate the reason why your client can't connect to Mongo.
Hi matt i was trying to run intergation testing on rest service endpoints with mongodb backend DB and i have added dependency of Mongodb in my pom.xml file . i was trying to build my spring boot app with "mvn clean install" this command build my project and run my test while running the spring boot app i was getting that error "Exception opening socket
at com.mongodb.connection.SocketStream.open" and i was not able to run my test it showing error like this :
017-04-26 06:58:23.215 INFO 117 --- [o-auto-1-exec-8] org.mongodb.driver.cluster : No server chosen by WritableServerSelector from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, all=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]}. Waiting for 30000 ms before timing out
2017-04-26 06:58:53.218 ERROR 117 --- [o-auto-1-exec-8] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.DataAccessResourceFailureException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. 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)}}]; 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=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]] with root cause
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=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]
at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:369) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.binding.ClusterBinding.getWriteConnectionSource(ClusterBinding.java:68) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:219) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:133) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:60) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.Mongo.execute(Mongo.java:781) ~[mongodb-driver-3.2.2.jar:na]
at com.mongodb.Mongo$2.execute(Mongo.java:764) ~[mongodb-driver-3.2.2.jar:na]
at com.mongodb.DBCollection.executeWriteOperation(DBCollection.java:333) ~[mongodb-driver-3.2.2.jar:na]
at com.mongodb.DBCollection.insert(DBCollection.java:328) ~[mongodb-driver-3.2.2.jar:na]
at com.mongodb.DBCollection.insert(DBCollection.java:319) ~[mongodb-driver-3.2.2.jar:na]
at com.mongodb.DBCollection.insert(DBCollection.java:289) ~[mongodb-driver-3.2.2.jar:na]
at com.mongodb.DBCollection.insert(DBCollection.java:255) ~[mongodb-driver-3.2.2.jar:na]
at com.mongodb.DBCollection.insert(DBCollection.java:192) ~[mongodb-driver-3.2.2.jar:na]
at org.springframework.data.mongodb.core.MongoTemplate$9.doInCollection(MongoTemplate.java:1034) ~[spring-data-mongodb-1.9.7.RELEASE.jar:na]
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:462) ~[spring-data-mongodb-1.9.7.RELEASE.jar:na]
at org.springframework.data.mongodb.core.MongoTemplate.insertDBObject(MongoTemplate.java:1029) ~[spring-data-mongodb-1.9.7.RELEASE.jar:na]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.