For some reason the following inserts to the remote mongo server when I run locally, but when I run on my appfog server it doesn't insert.
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');
});
});
});
}
My output is:
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
Do I need to specify some permissions somewhere?
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.
There are a few reasons you might fail to connect to the mongo service on AppFog. Here is a documentation url for how to get started with using Mongo on AppFog:
http://docs.appfog.com/services/mongodb
If that documentation does not work, you can reach out directly to their support at support@appfog.com or you can get feedback directly from customers in their active google group: https://groups.google.com/forum/#!forum/appfog-users