我正在尝试将Express应用程序部署到heroku并收到以下错误:
2013-01-28T12:44:55+00:00 heroku[web.1]: Starting process with command `coffee server.coffee`
2013-01-28T12:44:57+00:00 app[web.1]: Express server listening on port 13715
2013-01-28T12:44:57+00:00 app[web.1]: /app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/connection/server.js:537
2013-01-28T12:44:57+00:00 app[web.1]: ^
2013-01-28T12:44:57+00:00 app[web.1]: throw err;
2013-01-28T12:44:57+00:00 app[web.1]: at Db.indexInformation (/app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js:1372:30)
2013-01-28T12:44:57+00:00 app[web.1]: Error: Error setting TTL index on collection : sessions
2013-01-28T12:44:57+00:00 app[web.1]: at module.exports._get_collection (/app/node_modules/connect-mongo/lib/connect-mongo.js:137:23)
2013-01-28T12:44:57+00:00 app[web.1]: at Cursor.toArray (/app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js:152:22)
2013-01-28T12:44:57+00:00 app[web.1]: at Db.ensureIndex (/app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js:1228:28)
2013-01-28T12:44:57+00:00 app[web.1]: at Cursor.nextObject.self.queryRun (/app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js:594:39)
2013-01-28T12:44:57+00:00 app[web.1]: at Db._executeQueryCommand (/app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js:1814:5)
2013-01-28T12:44:57+00:00 app[web.1]: at Cursor.close (/app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js:947:5)
2013-01-28T12:44:57+00:00 app[web.1]: at Cursor.nextObject.commandHandler (/app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js:594:21)
2013-01-28T12:44:57+00:00 app[web.1]: at EventEmitter.emit (events.js:126:20)
2013-01-28T12:44:57+00:00 app[web.1]: at g (events.js:192:14)
当我在本地运行时,它工作正常。在这两种情况下,我都连接到MongoHQ。 以下是我的server.coffee的相关部分:
express = require 'express'
mongoStore = require("connect-mongo")(express)
app.configure ->
app.use express.errorHandler()
app.use express.logger("dev")
app.use express.bodyParser()
app.use express.methodOverride()
app.use express.cookieParser(config.cookieSecret)
app.use express.session(
secret: config.sessionSecret
cookie:
httpOnly: true
secure: true
store: new mongoStore(
url: config.db
collection: "sessions"
auto_reconnect: true
)
)
app.use express.csrf()
app.use express.static(config.root + "/public")
app.use assets()
app.use flash()
app.use passport.initialize()
app.use passport.session()
app.use app.router
我使用节点0.8.14,表示3.0.3,mongoose 3.4.0,connect-mongo 0.3.2。 任何帮助将不胜感激!
答案 0 :(得分:2)
我有同样的症状。通过使用this问题中的代码来获取更多错误信息;它帮助我意识到问题确实是我在连接字符串中的用户ID和密码。
答案 1 :(得分:0)
原来我的配置文件指向dev和prod中的同一个db。这就是导致错误的原因。