出于某种原因,当我在本地运行时,以下内容会插入到远程 mongo 服务器,但是当我在我的appfog服务器上运行时,它不会插入。
function record_visit(req, res){
res.write("<br/>Connecting to "+mongourl+"<br/>");
mongo.connect(mongourl, function(err, conn){
res.write("<br/>mongo.connect success. Err = "+err+"<br/>");
conn.collection('ips', function(err, coll){
res.write("<br/>conn.collection called on collection ips, err = "+err+"<br/>");
object_to_insert = { 'ip': req.connection.remoteAddress, 'ts': new Date() };
coll.insert( object_to_insert, {safe:true}, function(err){
res.write("Inserted in collection 'ips' Err= "+err);
res.end('<br/>Done\n');
});
});
});
}
我的输出是:
Connecting to [correct authenticated url to mongo here]
mongo.connect success. Err = null
conn.collection called on collection ips, err = null
Inserted in collection 'ips' Err= null
Done
我需要在某处指定一些权限吗?