pstoica / pow-viz

MIT License
2 stars 1 forks source link

failed to connect to [localhost:27017] #16

Closed camreon closed 10 years ago

camreon commented 10 years ago

i keep getting this connection error in data_aggregator.js from

MongoClient.connect(self.connectionURL, function(err, db)

i'm pretty sure i have mongodb installed. any ideas what's going on?

vis-123 commented 10 years ago

Open another terminal and run 'mongod' before running node.

pstoica commented 10 years ago

I also got this after sending a few requests in a row and the server crashed sometimes, idk, but everything was fine after starting it up again.

pstoica commented 10 years ago

jk, I get this:

TypeError: Cannot call method 'collection' of null
    at /Users/patrick/Documents/Code/pow-viz/data_aggregator.js:118:23
    at /Users/patrick/Documents/Code/pow-viz/node_modules/mongodb/lib/mongodb/mongo_client.js:372:11
    at process._tickCallback (node.js:415:13)

not a huge issue but I'm curious why that happens

camreon commented 10 years ago

oh, yea that's what i was getting before putting an error check in. must be the same problem

vis-123 commented 10 years ago

this is the error producing line: var collection = db.collection(self.collection);

i guess the db isn't getting initialized properly. not sure why, but we can def figure it out in class tomorrow. everything was working for me when i tested, must just be some minor difference in our setups.

this thing : localhost:27017 is usually the port that mongod is running on, which is what was making me think mongod was not running when you guys were getting the errors.

vis-123 commented 10 years ago

oh and it might be a problem if the collection hasn't already been created in mongodb.. i ran the csv importer and had all the data put into a collection named 'weed_data' I'm not sure if you guys had that collection yet.

pstoica commented 10 years ago

I have it working most of the time, it's just if I send multiple API requests quickly. I'll see if I can look something up about it.

pstoica commented 10 years ago

fixed this by opening one mongo connection when initializing DataAggregator.