mlab

How do I setup MongoDB database on Heroku with MongoLab?

梦想的初衷 提交于 2019-11-30 07:26:55
I'm using Express.js and MongoLab and I followed the Heroku setup to get MongoDB working in production throwing this code in my app.js . //Mongo on Heroku Setup var mongo = require('mongodb'); var mongoUri = process.env.MONGOLAB_URI || process.env.MONGOHQ_URL || 'mongodb://localhost/mydb'; mongo.Db.connect(mongoUri, function (err, db) { db.collection('mydocs', function(er, collection) { collection.insert({'mykey': 'myvalue'}, {safe: true}, function(er,rs) { }); }); }); and I have the following routes and field for my email form (also in app.js): //Routes app.get('/', function(req, res) { res

How do I setup MongoDB database on Heroku with MongoLab?

て烟熏妆下的殇ゞ 提交于 2019-11-29 09:31:13
问题 I'm using Express.js and MongoLab and I followed the Heroku setup to get MongoDB working in production throwing this code in my app.js . //Mongo on Heroku Setup var mongo = require('mongodb'); var mongoUri = process.env.MONGOLAB_URI || process.env.MONGOHQ_URL || 'mongodb://localhost/mydb'; mongo.Db.connect(mongoUri, function (err, db) { db.collection('mydocs', function(er, collection) { collection.insert({'mykey': 'myvalue'}, {safe: true}, function(er,rs) { }); }); }); and I have the

Handling MongoDB disconnect/reconnects from Node

…衆ロ難τιáo~ 提交于 2019-11-29 00:30:17
When my MongoDB connection is idle for a few minutes, the next request ends in error. From the mongo command line client, it looks like this: > db.users.find() Sat Jan 12 23:42:35 Socket recv() errno:54 Connection reset by peer 107.22.25.25:47207 Sat Jan 12 23:42:35 SocketException: remote: 107.22.25.25:47207 error: 9001 socket exception [1] server [107.22.25.25:47207] Sat Jan 12 23:42:35 DBClientCursor::init call() failed Sat Jan 12 23:42:35 query failed : chowology.users {} to: ds047207.mongolab.com:47207 Error: error doing query: failed Sat Jan 12 23:42:35 trying reconnect to ds047207

mongodb could not connect to server

大兔子大兔子 提交于 2019-11-28 02:03:53
问题 I'm new to MongoDB. I'm trying to connect to my remote mongo database from my work machine( I tried for both mongohq as well as mongolab). I'm getting the error listed below. When I run the same command from my home machine it runs fine and does connect to remove mongo database. I'm not sure what is messed up on my work machine but I'd like to fix it. Thanks for you help. MongoDB shell version: 2.4.9 connecting to: linus.mongohq.com:10097/mydb Thu Jan 16 04:16:02.689 Error: couldn't connect

java.lang.NoClassDefFoundError when using MongoDB driver

亡梦爱人 提交于 2019-11-28 01:32:47
I am trying to connect to a MongoDB database hosted on mlab using the Java driver on a servlet. import org.bson.Document; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; public class MongoConnection { protected void connectToMongo(String loc){ String dbName = "readings"; String collection = "data"; MongoClientURI uri = new MongoClientURI("mongodb://user:pass@ds143109.mlab.com:43109/readings"); MongoClient client = new MongoClient(uri); MongoDatabase db = client.getDatabase(dbName);

can't connect to mongolab with node.js on heroku

女生的网名这么多〃 提交于 2019-11-27 22:24:11
问题 I am having trouble making node.js and mongodb with mongolab work on heroku. I have read other issues like How do I setup MongoDB database on Heroku with MongoLab? and How do I manage MongoDB connections in a Node.js web application? but I still can not set up my connection. In the logs it says [Error: failed to connect to ...] I have takend the db, host and port from the MONGOLAB_URI process env.I have the following code: var mongoUri = mongodb://heroku_app17328644:{password}@ds037518

Handling MongoDB disconnect/reconnects from Node

戏子无情 提交于 2019-11-27 21:29:52
问题 When my MongoDB connection is idle for a few minutes, the next request ends in error. From the mongo command line client, it looks like this: > db.users.find() Sat Jan 12 23:42:35 Socket recv() errno:54 Connection reset by peer 107.22.25.25:47207 Sat Jan 12 23:42:35 SocketException: remote: 107.22.25.25:47207 error: 9001 socket exception [1] server [107.22.25.25:47207] Sat Jan 12 23:42:35 DBClientCursor::init call() failed Sat Jan 12 23:42:35 query failed : chowology.users {} to: ds047207

Does mongoDB have reconnect issues or am i doing it wrong?

情到浓时终转凉″ 提交于 2019-11-27 17:07:04
I'm using nodejs and a mongoDB - and I'm having some connection issues. Well, actually "wake" issues! It connects perfectly well - is super fast and I'm generally happy with the results. My problem: If i don't use the connection for a while (i say while, because the timeframe varies 5+ mins) it seems to stall. I don't get disconnection events fired - it just hangs. Eventually i get a response like Error: failed to connect to [ * .mongolab.com: * ] - ( * = masked values) A quick restart of the app, and the connection's great again. Sometimes, if i don't restart the app, i can refresh and it

Why is PyMongo 3 giving ServerSelectionTimeoutError?

时间秒杀一切 提交于 2019-11-27 11:54:59
I'm using: Python 3.4.2 PyMongo 3.0.2 mongolab running mongod 2.6.9 uWSGI 2.0.10 CherryPy 3.7.0 nginx 1.6.2 uWSGI start params: --socket 127.0.0.1:8081 --daemonize --enable-threads --threads 2 --processes 2 I setup my MongoClient ONE time: self.mongo_client = MongoClient('mongodb://user:pw@host.mongolab.com:port/mydb') self.db = self.mongo_client['mydb'] I try and save a JSON dict to MongoDB: result = self.db.jobs.insert_one(job_dict) It works via a unit test that executes the same code path to mongodb. However when I execute via CherryPy and uWSGI using an HTTP POST, I get this: pymongo

A timeout occured after 30000ms selecting a server using CompositeServerSelector

亡梦爱人 提交于 2019-11-27 09:14:59
I try to deploy my Mongo database in Mongolabs, everything works fine, and I create a new database. Please see my connectionstring. public DbHelper() { MongoClientSettings settings = new MongoClientSettings() { Credentials = new MongoCredential[] { MongoCredential.CreateCredential("dbname", "username", "password") }, Server = new MongoServerAddress("ds011111.mongolab.com", 11111), //ConnectTimeout = new TimeSpan(30000) }; Server = new MongoClient(settings).GetServer(); DataBase = Server.GetDatabase(DatabaseName); } but when I try to connect the database it's shows error like: Ragesh S I am