meanjs app deploy mongodb connection fails but works local - mongodb

meanjs app, database connection fail (mongoHQ), string hard coded:
db: 'mongodb://user:pass#server.mongohq.com/db_name'
1) package.json: https://gist.github.com/anonymous/c864fbc2572bd10f7e90
2) log error: https://gist.github.com/anonymous/09726b7458560fe8e5f3
3) jitsu v0.14.0, node v0.10.33 and npm v2.1.8
4) platform : linux
db string above is used for development and production environment for testing purpose. Issue is that I can connect and add entries to the database in a local environment (dev env) but once I deploy or push to either herokuapp or nodejitsu I get the following error:
nodejitsu log:
out Wed, 19 Nov 2014 23:39:34 GMT
out Wed, 19 Nov 2014 23:39:34 GMT Application loaded using the "production" environment configuration
out Wed, 19 Nov 2014 23:39:34 GMT
err Wed, 19 Nov 2014 23:39:36 GMT
err Wed, 19 Nov 2014 23:39:36 GMT events.js:72
err Wed, 19 Nov 2014 23:39:36 GMT ^
err Wed, 19 Nov 2014 23:39:36 GMT throw er; // Unhandled 'error' event
err Wed, 19 Nov 2014 23:39:36 GMT Error: failed to connect to [localhost:27017]
at null. (/opt/run/snapshot/package/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:549:74)
at emit (events.js:106:17)
at null. (/opt/run/snapshot/package/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:150:15)
at emit (events.js:98:17)
at Socket. (/opt/run/snapshot/package/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:533:10)
at Socket.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:419:13)
heroku log:
2014-11-19T23:27:22.425635+00:00 app[web.1]: MEAN.JS application started on port 15050
2014-11-19T23:27:22.430865+00:00 app[web.1]: events.js:72
2014-11-19T23:27:22.434306+00:00 app[web.1]: ^
2014-11-19T23:27:22.430483+00:00 app[web.1]:
2014-11-19T23:27:22.436997+00:00 app[web.1]: at emit (events.js:106:17)
2014-11-19T23:27:22.437004+00:00 app[web.1]: at Socket.emit (events.js:95:17)
2014-11-19T23:27:22.437006+00:00 app[web.1]: at net.js:440:14
2014-11-19T23:27:22.431432+00:00 app[web.1]: throw er; // Unhandled 'error' event
2014-11-19T23:27:22.436991+00:00 app[web.1]: Error: failed to connect to [localhost:27017]
2014-11-19T23:27:22.436996+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:549:74)
2014-11-19T23:27:22.436999+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:150:15)
2014-11-19T23:27:22.437001+00:00 app[web.1]: at emit (events.js:98:17)
2014-11-19T23:27:22.437003+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:533:10)
2014-11-19T23:27:22.437008+00:00 app[web.1]: at process._tickCallback (node.js:419:13)
2014-11-19T23:27:22.452476+00:00 app[web.1]: error: Forever detected script exited with code: 8

I found a connection code in one of my models needed for an auto-increment plugin.
var connection = mongoose.createConnection('mongodb://localhost/n-express-dev');
replaced with the following to get it to deploy without errors.
var connection = mongoose.createConnection(process.env.MONGOHQ_URI || process.env.MONGOLAB_URI || 'mongodb://localhost/n-express-dev');

Related

MeteorJS MongoDB Deploy Error

For some reason when I use Meteor deploy my server produces the following error and I am unable to access the pages. I'm running into the following error:
WARNING Error: No replica set primary available for query with
ReadPreference PRIMARY
I am using Meteor 1.1.0.2 and run meteor deploy x.meteor.com. The logs are then queried via meteor logs x.meteor.com. It was working up until recently.
Any help would be appreciated, the full meteor log output is below.
[Tue May 05 2015 20:50:15 GMT+0000 (UTC)] WARNING
/meteor/dev_bundles/0.4.18/lib/node_modules/fibers/future.js:245
throw(ex); [Tue May 05 2015 20:50:15 GMT+0000 (UTC)] WARNING
^ [Tue May 05 2015 20:50:15 GMT+0000 (UTC)] WARNING Error: No replica
set primary available for query with ReadPreference PRIMARY at
Object.Future.wait
(/meteor/dev_bundles/0.4.18/lib/node_modules/fibers/future.js:395:16)
at [object Object].MongoConnection._ensureIndex
(packages/mongo/mongo_driver.js:733:1) at [object
Object].Mongo.Collection._ensureIndex
(packages/mongo/collection.js:620:1) at Accounts.urls
(packages/accounts-base/accounts_server.js:1309:1) at
/meteor/containers/93192c1f-5c41-157d-36a5-dceb494f7e2c/bundle/programs/server/packages/accounts-base.js:1616:4
at
/meteor/containers/93192c1f-5c41-157d-36a5-dceb494f7e2c/bundle/programs/server/packages/accounts-base.js:1659:3
at
/meteor/containers/93192c1f-5c41-157d-36a5-dceb494f7e2c/bundle/programs/server/boot.js:222:10
at Array.forEach (native) at Function..each..forEach
(/meteor/dev_bundles/0.4.18/lib/node_modules/underscore/underscore.js:79:11)
at
/meteor/containers/93192c1f-5c41-157d-36a5-dceb494f7e2c/bundle/programs/server/boot.js:117:5
at [object Object].ReplSet.checkoutReader
(/meteor/containers/93192c1f-5c41-157d-36a5-dceb494f7e2c/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/repl_set/repl_set.js:613:14)
at Cursor.nextObject
(/meteor/containers/93192c1f-5c41-157d-36a5-dceb494f7e2c/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/cursor.js:748:48)
at Cursor.toArray
(/meteor/containers/93192c1f-5c41-157d-36a5-dceb494f7e2c/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/cursor.js:169:10)
at Db.indexInformation
(/meteor/containers/93192c1f-5c41-157d-36a5-dceb494f7e2c/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/db.js:1629:39)
at Db.ensureIndex
(/meteor/containers/93192c1f-5c41-157d-36a5-dceb494f7e2c/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/db.js:1496:8)
at Collection.ensureIndex
(/meteor/containers/93192c1f-5c41-157d-36a5-dceb494f7e2c/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/collection/index.js:68:11)
at [object Object].MongoConnection._ensureIndex
(packages/mongo/mongo_driver.js:732:1) at [object
Object].Mongo.Collection._ensureIndex
(packages/mongo/collection.js:620:1) at Accounts.urls
(packages/accounts-base/accounts_server.js:1309:1) at
/meteor/containers/93192c1f-5c41-157d-36a5-dceb494f7e2c/bundle/programs/server/packages/accounts-base.js:1616:4
[Tue May 05 2015 20:50:15 GMT+0000 (UTC)] INFO STATUS running ->
starting [Tue May 05 2015 20:50:15 GMT+0000 (UTC)] ERROR Application
crashed with code: 8 [Tue May 05 2015 20:50:15 GMT+0000 (UTC)] NOTICE
Starting application on port 23497 [Tue May 05 2015 20:50:15 GMT+0000
(UTC)] INFO STATUS starting -> running
For future reference: This generally indicates an issue with the MongoDB and the driver being unable to connect.
Right at this very moment is seems numerous people are having this problem with their *.meteor.com applications. I would wait a bit and then try to redeploy.

Error setting TTL index on collection

I'm getting the following issue using KeystoneJs v3.
Hosted on Azure, with a MongoLab hosting the database. I don't get this error whilst accessing the db via KeystoneJs on localhost
I'm pretty fresh to KeystoneJs, node and mongo, so apologies if this has been asked and solved many times before.
Thu Feb 19 2015 21:23:13 GMT+0000 (Coordinated Universal Time): Unaught exception: Error: Error setting TTL index on collection : app_sessions
at D:\home\site\wwwroot\node_modules\connect-mongo\lib\connect-mongo.js:169:23
at D:\home\site\wwwroot\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\db.js:1482:46
at D:\home\site\wwwroot\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\db.js:1615:20
at D:\home\site\wwwroot\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\cursor.js:169:22
at D:\home\site\wwwroot\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\cursor.js:700:39
at Cursor.close (D:\home\site\wwwroot\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\cursor.js:989:5)
at Cursor.wrappedCursorClose [as close] (D:\home\site\wwwroot\node_modules\newrelic\lib\instrumentation\mongodb.js:226:20)
at commandHandler (D:\home\site\wwwroot\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\cursor.js:700:21)
at D:\home\site\wwwroot\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\db.js:1888:9
at Server.Base._callHandler (D:\home\site\wwwroot\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\connection\base.js:453:41)
at D:\home\site\wwwroot\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\connection\server.js:487:18
at MongoReply.parseBody (D:\home\site\wwwroot\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\responses\mongo_reply.js:68:5)
at null.<anonymous> (D:\home\site\wwwroot\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\connection\server.js:445:20)
at emit (events.js:95:17)
at null.<anonymous> (D:\home\site\wwwroot\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\connection\connection_pool.js:201:13)
at emit (events.js:98:17)

IHS webserver connecting to websphere application server

I have one applicaion server having multiple nodes. When I am connecting the application through application server, it is working fine. But when I am connecting the application through webserver, it is not working for one node and for all other nodes it works.
What would be the possible cause. I have re-configured the plugin for that particular node many a times. no luck.
I see below logs in plugin log (date may change):
*[Mon Aug 10 11:53:50 2009] 00001dec 00001e04 - ERROR: ws_common: websphereGetStream: Failed to connect to app server on host 'windowsinternal.pt', OS err=78
[Mon Aug 10 11:53:51 2009] 00001dec 00001e04 - ERROR: ws_common: websphereGetStream: Failed to connect to app server on host 'windowsinternal.pt', OS err=78
[Mon Aug 10 11:53:51 2009] 00001dec 00001e04 - ERROR: ws_common: websphereExecute: Failed to create the stream
[Mon Aug 10 11:53:51 2009] 00001dec 00001e04 - ERROR: ws_common: websphereHandleRequest: Failed to execute the transaction to 'windowsinternalNode01_server1'on host 'windowsinternal.pt'; will try another one
[Mon Aug 10 11:53:51 2009] 00001dec 00001e04 - ERROR: ws_common: websphereWriteRequestReadResponse: Failed to find an app server to handle this request
[Mon Aug 10 11:53:51 2009] 00001dec 00001e04 - ERROR: ESI: getResponse: failed to get response: rc = 2
[Mon Aug 10 11:53:51 2009] 00001dec 00001e04 - ERROR: ws_common: websphereHandleRequest: Failed to handle request
[Mon Aug 10 11:53:52 2009] 00001dec 000015b4 - ERROR: ws_common: websphereGetStream: Failed to connect to app server on host 'windowsinternal.pt', OS err=78*
this issue was resolved. There was firewall issue with the default secure port. I just changed the port and it worked.

MeteorJS Mongo connection timed out

I have a MeteorJS app that is not connecting to Mongo. It's been deployed using meteor deploy but for some reason it times out when trying to connect to the database :S I can still access the mongo database using meteor mongo and all of the data is present!
I am using Meteor 0.9.3.1 and here are my packages:
standard-app-packages
insecure
underscore
arunoda:npm#0.2.6
mrt:bootstrap-3
http
iron:router
mrt:q#0.9.7
mrt:moment#2.8.1
mrt:twilio-meteor
email
Here are the logs from meteor logs :
[Thu Oct 16 2014 17:39:25 GMT+0000 (UTC)] INFO Exception in setInterval callback: MongoError: connection to [production-db-a3.meteor.io:27017] timed out
at Object.Future.wait (/meteor/dev_bundles/0.3.55/lib/node_modules/fibers/future.js:326:15)
at _.extend._nextObject (packages/mongo/mongo_driver.js:858)
at _.extend.forEach (packages/mongo/mongo_driver.js:892)
at _.extend.map (packages/mongo/mongo_driver.js:902)
at _.extend.fetch (packages/mongo/mongo_driver.js:926)
at Cursor.(anonymous function) [as fetch] (packages/mongo/mongo_driver.js:741)
at Object.residentModel.getActiveResidents (app/shared/collections/residents.js:43:40)
at Object._.extend._run (app/server/services/deviceService/sensorChangeWatchdog.js:6:39)
at app/lib/watchdogFactory.js:7:12
at _.extend.withValue (packages/meteor/dynamics_nodejs.js:56)
- - - - -
at Object.toError (/meteor/containers/450809a5-5a17-5e6e-8233-85e6ad895366/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/utils.js:110:11)
at commandHandler (/meteor/containers/450809a5-5a17-5e6e-8233-85e6ad895366/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/cursor.js:679:63)
at null.<anonymous> (/meteor/containers/450809a5-5a17-5e6e-8233-85e6ad895366/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/db.js:1843:9)
at g (events.js:180:16)
at emit (events.js:98:17)
at Base.__executeAllServerSpecificErrorCallbacks (/meteor/containers/450809a5-5a17-5e6e-8233-85e6ad895366/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/base.js:365:29)
at Server.<anonymous> (/meteor/containers/450809a5-5a17-5e6e-8233-85e6ad895366/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/repl_set/ha.js:445:10)
at Server.g (events.js:180:16)
at Server.emit (events.js:98:17)
at null.<anonymous> (/meteor/containers/450809a5-5a17-5e6e-8233-85e6ad895366/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/server.js:501:88)
[Thu Oct 16 2014 17:41:05 GMT+0000 (UTC)] INFO STATUS running -> killed
[Thu Oct 16 2014 17:41:05 GMT+0000 (UTC)] NOTICE Starting application on port 19159
[Thu Oct 16 2014 17:41:05 GMT+0000 (UTC)] INFO STATUS killed -> starting
[Thu Oct 16 2014 17:41:06 GMT+0000 (UTC)] INFO STATUS starting -> running
[Thu Oct 16 2014 17:41:07 GMT+0000 (UTC)] INFO init

error during mongo db.shutdownServer()

I got the following error when I try to shutdown mongodb in my VM Ubuntu.
I am running 12.10 Ubuntu headless server.
The current Mongodb Shell Version is 2.0.6
use admin
switched to db admin
> db.shutdownServer()
Tue Dec 10 14:17:03 DBClientCursor::init call() failed
Tue Dec 10 14:17:03 query failed : admin.$cmd { shutdown: 1.0 } to: 127.0.0.1
server should be down...
Tue Dec 10 14:17:03 trying reconnect to 127.0.0.1
Tue Dec 10 14:17:03 reconnect 127.0.0.1 ok
Tue Dec 10 14:17:03 Socket recv() errno:104 Connection reset by peer 127.0.0.1:27017
Tue Dec 10 14:17:03 SocketException: remote: 127.0.0.1:27017 error: 9001 socket exception [1] server [127.0.0.1:27017]
Tue Dec 10 14:17:03 DBClientCursor::init call() failed
Tue Dec 10 14:17:03 query failed : admin.$cmd { getlasterror: 1.0, w: 1.0 } to: 127.0.0.1
Tue Dec 10 14:17:03 Error: error doing query: failed shell/collection.js:151
What should I do?
My reason for trying to shut it down is because I want to update to mongo 2.2.
Please advise.
Although the messaging is confusing, this is actually expected behaviour if you shutdown via the mongo shell. Since you ran the db.shutdownServer() command through the mongo shell it can no longer connect to the server and this is essentially indicating the shell has been disconnected.
The mongo shell tries to automatically reconnect when you hit enter, which results in the messages like "trying to reconnect ...".
There is an open issue to improve this behaviour/messaging if you'd like to upvote/watch it: SERVER-5467.