com.mongodb.MongoTimeoutException on Mac OS X

607 views
Skip to first unread message

Eun-Jeong Shin

unread,
May 27, 2015, 11:35:12 PM5/27/15
to mongod...@googlegroups.com
Hello, all.

I am getting these errors when I run command. Most test cases are failing because of this connection error.

> gradle test

com.mongodb.DBTest > shouldThrowErrorwhileDoingEval FAILED

com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches PrimaryServerSelector. 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}}]

I downloaded java driver code from here :

https://github.com/mongodb/mongo-java-driver

Can anyone help on this? Is this related to the issue https://jira.mongodb.org/browse/JAVA-510 ?

If I need to change any configuration to connect to server, please guide.

Eun-Jeong Shin

unread,
May 27, 2015, 11:39:17 PM5/27/15
to mongod...@googlegroups.com
Here's the error in detail if i run QuickTour.java

INFO: Exception in monitor thread while connecting to server localhost:27017

com.mongodb.MongoInternalException: Opening the AsynchronousSocketChannelStream failed

at com.mongodb.connection.FutureAsyncCompletionHandler.get(FutureAsyncCompletionHandler.java:65)

at com.mongodb.connection.FutureAsyncCompletionHandler.getOpen(FutureAsyncCompletionHandler.java:43)

at com.mongodb.connection.AsynchronousSocketChannelStream.open(AsynchronousSocketChannelStream.java:60)

at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114)

at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:127)

at java.lang.Thread.run(Thread.java:745)

Caused by: com.mongodb.MongoSocketOpenException: Exception opening socket

at com.mongodb.connection.AsynchronousSocketChannelStream$1.failed(AsynchronousSocketChannelStream.java:86)

at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:128)

at sun.nio.ch.Invoker$2.run(Invoker.java:218)

at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

... 1 more

Caused by: java.net.ConnectException: Connection refused

at sun.nio.ch.UnixAsynchronousSocketChannelImpl.checkConnect(Native Method)

at sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishConnect(UnixAsynchronousSocketChannelImpl.java:252)

at sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:198)

at sun.nio.ch.UnixAsynchronousSocketChannelImpl.onEvent(UnixAsynchronousSocketChannelImpl.java:213)

at sun.nio.ch.KQueuePort$EventHandlerTask.run(KQueuePort.java:301)

... 1 more

Jeff Yemin

unread,
May 28, 2015, 9:23:33 AM5/28/15
to mongod...@googlegroups.com
Before running the tests, you must start a mongod server on port 27017 beforehand.  Have you done that?

Regards,
Jeff
Reply all
Reply to author
Forward
0 new messages