val _mongoClient = MongoClient("mongodb://localhost")
val _database = _mongoClient.getDatabase("db")
val _collection = _database.getCollection("xyz")
INFO org.mongodb.driver.cluster - Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}INFO org.mongodb.driver.cluster - Exception in monitor thread while connecting to server localhost:27017com.mongodb.MongoException: java.io.IOException: ConnectEx failed at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:125) at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128) at java.lang.Thread.run(Thread.java:745)Caused by: java.io.IOException: ConnectEx failed at sun.nio.ch.WindowsAsynchronousSocketChannelImpl.connect0(Native Method) at sun.nio.ch.WindowsAsynchronousSocketChannelImpl.access$200(WindowsAsynchronousSocketChannelImpl.java:43) at sun.nio.ch.WindowsAsynchronousSocketChannelImpl$ConnectTask.run(WindowsAsynchronousSocketChannelImpl.java:235) at sun.nio.ch.WindowsAsynchronousSocketChannelImpl.implConnect(WindowsAsynchronousSocketChannelImpl.java:382) at sun.nio.ch.AsynchronousSocketChannelImpl.connect(AsynchronousSocketChannelImpl.java:209) at com.mongodb.connection.AsynchronousSocketChannelStream.openAsync(AsynchronousSocketChannelStream.java:79) at com.mongodb.connection.AsynchronousSocketChannelStream.open(AsynchronousSocketChannelStream.java:61) at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114) ... 2 common frames omittedINFO org.mongodb.driver.cluster - No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, all=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoException: java.io.IOException: ConnectEx failed}, caused by {java.io.IOException: ConnectEx failed}}]}. Waiting for 30000 ms before timing outException in thread "main" 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=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoException: java.io.IOException: ConnectEx failed}, caused by {java.io.IOException: ConnectEx failed}}] at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:369) at com.mongodb.connection.BaseCluster.handleServerSelectionRequest(BaseCluster.java:283) at com.mongodb.connection.BaseCluster.access$800(BaseCluster.java:51) at com.mongodb.connection.BaseCluster$WaitQueueHandler.run(BaseCluster.java:450) at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: ConnectEx failed
Does anybody know what's going on here?
Hi Josh,
Looking at your exception error log, it looks like an error related to Windows ConnectEx function.
I have no problems connecting to the mongo shell through a client.
Did you mean to say, that you are able to connect to mongod
via the mongo shell client ?
If not, could you elaborate what did you mean by 'through a client' ?
It is not part of a replica set and there is absolutely nothing fancy going on with the setup.
To clarify, do you have a standalone MongoDB instance running locally on the default port 27017
?
Could you also provide the following relevant information:
MongoDB Scala driver version.
Scala version.
Specific MongoDB version. i.e. version 3.2.10
Specific Operating Systems version.
Regards,
Wan.
Any help would be highly appreciated I also asked a question on SO
Hi Fred,
Looks like your question has been answered on the StackOverflow link you provided.
For future reference, please open a new discussion thread. Although you may share the same general question on connecting using the Scala driver, it may be a different issue altogether. Also the original question was posted in 2016, there has been many changes/improvements since.
Kind regards,
Wan.