我对nodejs很陌生并且遇到麻烦。 我使用statsd收集统计信息,然后将它们发送到mongodb服务器进行存储, 但是当我将statsd的计时器数据发送到mongodb时,我遇到了这个问题。
/home/cadofa/node_modules/mongo-statsd-
backend/node_modules/mongodb/lib/mongodb/connection/base.js:245
throw message;
^
TypeError: Cannot call method 'insert' of null
at /home/cadofa/node_modules/mongo-statsd-backend/lib/index.js:161:15
at /home/cadofa/node_modules/mongo-statsd-
backend/node_modules/mongodb/lib/mongodb/db.js:1011:22
at /home/cadofa/node_modules/mongo-statsd-
backend/node_modules/mongodb/lib/mongodb/db.js:1130:16
at /home/cadofa/node_modules/mongo-statsd-
backend/node_modules/mongodb/lib/mongodb/db.js:1846:9
at Server.Base._callHandler (/home/cadofa/node_modules/mongo-statsd-
backend/node_modules/mongodb/lib/mongodb/connection/base.js:445:41)
at /home/cadofa/node_modules/mongo-statsd-
backend/node_modules/mongodb/lib/mongodb/connection/server.js:478:18
at MongoReply.parseBody (/home/cadofa/node_modules/mongo-statsd-
backend/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
at null.<anonymous> (/home/cadofa/node_modules/mongo-statsd-
backend/node_modules/mongodb/lib/mongodb/connection/server.js:436:20)
at EventEmitter.emit (events.js:95:17)
at null.<anonymous> (/home/cadofa/node_modules/mongo-statsd-
backend/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:201:13)
任何能告诉我如何解决问题的人,非常感谢!
答案 0 :(得分:0)
确保您已连接到mongodb服务器。看来你的连接是空的!
答案 1 :(得分:0)
答案就在这里,现在它已经被github修复了。 https://github.com/dynmeth/mongo-statsd-backend/pull/8/files