2

出于某种原因,当我在本地运行时,以下内容会插入到远程 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

我需要在某处指定一些权限吗?

4

2 回答 2

0

you can try to use the --bind_ip arg on mongod to bind the server to the actual ip of the machine. Default behavior is listening to all local ip's but that might no mean its bound to the real ip of the server.

于 2012-09-25T09:35:59.997 回答
0

您可能无法连接到 AppFog 上的 mongo 服务有几个原因。以下是有关如何开始在 AppFog 上使用 Mongo 的文档网址:

http://docs.appfog.com/services/mongodb

如果该文档不起作用,您可以通过 support@appfog.com 直接联系他们的支持,或者您可以直接从他们活跃的 google 组中的客户那里获得反馈:https ://groups.google.com/forum/#!forum /appfog-用户

于 2012-09-25T19:43:13.503 回答