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 の使用を開始する方法に関するドキュメントの URL は次のとおりです。

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

そのドキュメントが機能しない場合は、support@appfog.com でサポートに直接連絡するか、アクティブな Google グループ ( https://groups.google.com/forum/#!forum ) で顧客から直接フィードバックを得ることができます。 /appfog-ユーザー

于 2012-09-25T19:43:13.503 に答える