我在 grails 中使用 gorm 连接到 MongoDB。我收到 MongoTimeOutException。 我能够使用 mongo java 驱动程序独立程序成功连接到 MongoDb。 为什么我无法通过 Grails GORM 插件连接?
有人可以帮忙吗? 下面是配置
grails {
mongo {
host = "localhost"
port = 27107
databaseName = "test"
options{
connectionsPerHost=20
}
}
}
下面是领域类
class Device {
String deviceType
String deviceId
int primary
static constraints = {
}
}
下面是异常trace
| Error 2014-11-09 16:10:39,620 [http-bio-8080-exec-4] ERROR errors.GrailsExceptionResolver - MongoTimeoutException occurred when processing request: [GET] /devices/Device
Timed out while waiting to connect after 10000 ms. Stacktrace follows:
Message: Timed out while waiting to connect after 10000 ms
Line | Method
->> 131 | getDescription in com.mongodb.BaseCluster
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 396 | getClusterDescription in com.mongodb.DBTCPConnector
| 569 | getType . . . . . . . in ''
| 370 | isMongosConnection in ''
| 645 | isMongosConnection . in com.mongodb.Mongo
| 454 | _check in com.mongodb.DBCursor
| 546 | _hasNext . . . . . . in ''
| 571 | hasNext in ''
| 1893 | hasNext . . . . . . . in org.grails.datastore.mapping.mongo.query.MongoQuery$MongoResultList$1
| 8 | index in ewents.DeviceController
| 198 | doFilter . . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 895 | runTask . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
| 918 | run in ''
^ 695 | run . . . . . . . . . in java.lang.Thread
或者有人可以分享带有 GORM 支持的示例 Grails 示例吗?我基本上是这个 Grails 的新手。
最佳答案
我想通了这个问题。这是我的错,因为端口号是 27107 而不是 27017,我花了一天时间才弄明白。哈哈
关于mongodb - MongoTimeoutException 消息 : Timed out while waiting to connect after 10000 ms,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26827439/