Meteor deploying on Modulus - mongodb

Modulus deployments is perfect without any problems, but is not working. I have created a database on Modulus with the same name on the Meteor app.
http://wikimicroscope-13216.onmodulus.net/
Console log in Modulus:
Error: URL must be in the format mongodb://user:pass#host:port/dbname
at Error (<anonymous>)
at exports.parse (/mnt/data/2/node_modules/mongodb/lib/mongodb/connection/url_parser.js:15:11)
at Function.MongoClient.connect (/mnt/data/2/node_modules/mongodb/lib/mongodb/mongo_client.js:164:16)
at Function.Db.connect (/mnt/data/2/node_modules/mongodb/lib/mongodb/db.js:2035:23)
at new MongoConnection (packages/mongo-livedata/mongo_driver.js:151)
at new MongoInternals.RemoteCollectionDriver (packages/mongo-livedata/remote_collection_driver.js:4)
at Object.<anonymous> (packages/mongo-livedata/remote_collection_driver.js:44)
at Object.defaultRemoteCollectionDriver (packages/underscore/underscore.js:750)
at new Meteor.Collection (packages/mongo-livedata/collection.js:72)
at packages/accounts-base/accounts_common.js:122
[2014-05-23T16:02:46.435Z] Application CRASH detected. Exit code 8.
[2014-05-23T16:02:47.472Z] Application restarted.
I have set mongo_url and root_url before. Here are my environment variables:
CONNECTION STRINGS
MONGO URI
mongodb://<user>:<pass>#novus.modulusmongo.net:27017/iZ3anope
MONGO CONSOLE
mongo novus.modulusmongo.net:27017/iZ3anope -u <user> -p <pass>
I have deployed with different node versions like v0.10.25, v0.10.28. It is not working.
Beside on the browser there is the messages:
!Unable to connect to any application instances.!
and in the console inspector in Chrome / local store I find a message like this:
BiDefender_BLock {"verdict":"TRACKER","hitList":""}
Thanks!

You need to fill in <user>:<pass> with the username and password you set for the database.

I had this error and solve it by executing:
modulus env set MONGO_URL "mongodb://myUser:myPass#proximus.modulusmongo.net:27017/6sd54f5f?autoReconnect=true&connectTimeoutMS=60000"
instead of:
modulus env set MONGO_URL "mongodb://myUser:myPass#proximus.modulusmongo.net:27017/6sd54f5f ?autoReconnect=true&connectTimeoutMS=60000"
If you see, I added an extra space before the '?'
When I look at logs in modulus web interface, it told me database name cannot contains character ' ' (space)

I also just had this problem and fixed it by restarting my app

Related

How to get secret from Secret Manager in serverless

I configured a secret to my RDS database. Its name is: qa/aurora
I am trying to make the reference on my serverless.yml in the environment settings like this:
DB: ${ssm:/aws/reference/secretsmanager/qa/aurora~true}
I want to use this DB environment variable to set the user and password to my Aurora database.
The problem is that I am getting this error:
ServerlessError: An error occurred: testLambdaFunction - Properties validation failed for resource testLambdaFunction with message:
#/Environment/Variables/DB: expected type: String, found: JSONObject.
at C:\Users\fer\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\lib\monitorStack.js:94:23
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async AwsDeploy.update (C:\Users\fer\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\lib\updateStack.js:144:5)
According to the Serverless docs, it should be working fine with getting a JSONObject.
What I am missing to make this work?
PS: Why should I add ~true at the end of the string to find the secret? If I remove this value i get the error:
A valid SSM parameter to satisfy the declaration 'ssm:/aws/reference/secretsmanager/qa/aurora' could not be found.
The problema was that i was nesting the 3 levels down the code:
DB: ${ssm:/aws/reference/secretsmanager/qa/aurora~true}
As soon as i change it to the same level of the environment attribute it worked

MongoDB connecting to Node on AWS Mean stack

I have been trying for a few days to connect my mongoDB to MEAN stack without success. Its running on AWS lightsail (Bitnami). The website itself is running fine, except for any pages that have an ajax/db call, as the database is not connecting/authenticating my connection string.
I am using the mongo,node, express part of the stack, I do not need or know any angular at present. I thought this would be easier than setting up on nodeJS and then adding mongoDB separately (well i did try that first with similar problems), I do intend to learn angualar in future so this is probably better long term. Server side set up is currently a weakness.
I am using mongoose for the connection. I can access the database using:
mongo admin --username root -p password via SSH.
I can also access the db via Rockmongo SSH. There is currently only one admin user in the database at present i.e. root.
My initial server/startup file is below:
server.js
const app = require('/opt/bitnami/apps/MYAPP/app.js');
require('dotenv').config({ path: 'variables.env' });
const mongoose = require("mongoose");
mongoose.Promise = global.Promise;
mongoose.connect(process.env.DATABASE_CONN);
app.listen(3000,function(){
console.log("Server has started!");
});
variables.env
DATABASE_CONN = mongodb://root:password#127.0.0.1:27017/MYAPPDATABASE
I have also tried many other connections strings, exchanging root for bitnami default user, etc.
When I go to my app folder and start the server (npm start or node server.js), the website starts up but with the below mongoDB authentication errors, below is only the first section.
> Server has started!
Connection error: { MongoError: Authentication failed.
at /opt/bitnami/apps/MYAPP/node_modules/mongoose/node_modules/mongodb-core/lib/con
nection/pool.js:595:61
at authenticateStragglers (/opt/bitnami/apps/MYAPP/node_modules/mongoose/node_modu
les/mongodb-core/lib/connection/pool.js:513:16)
at Connection.messageHandler (/opt/bitnami/apps/MYAPP/node_modules/mongoose/node_m
odules/mongodb-core/lib/connection/pool.js:549:5)
at emitMessageHandler (/opt/bitnami/apps/MYAPP/node_modules/mongoose/node_modules/
mongodb-core/lib/connection/connection.js:309:10)
at Socket.<anonymous> (/opt/bitnami/apps/MYAPP/node_modules/mongoose/node_modules/
mongodb-core/lib/connection/connection.js:452:17)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:597:20)
name: 'MongoError',
message: 'Authentication failed.',
ok: 0,
errmsg: 'Authentication failed.',
code: 18,
codeName: 'AuthenticationFailed' }
Any help or direction would be much appreciated. Thank you kindly.
Mos.
OK. Solution found.
In the mongo.conf file I set the dbpath to /data/db
The mongo shell is pointed to /opt/bitnami/mongodb/tmp/mongodb-27017.sock "$#"
go to /opt/bitnami/mongodb/bin/mongo
change /opt/bitnami/mongodb/tmp/mongodb-27017.sock "$#" to /tmp/mongodb-27017.sock "$#"
Can do that using sudo nano /opt/bitnami/mongodb/bin/mongo then edit the file.
Still have noauth turned on, so next step is getting my db connection string to authenticate.
Hope it helps someone.
Thanks
Some improvement. I have edited mongo.conf for now to enable no auth. I then ran mongod which stated no /data/db folder for which it stores data. So I created the folders and ran mongod again. Now all pages work but the mongo shell command 'mongo' will not work on the terminal.
I think its because the mongod dbpath is set to data/db and the mongodb conf file dbpath is set to /opt/bitnami/mongodb/data/db.
So I am trying to update the mongod dbpath but it doesnt seem to update.

Error: database names cannot contain the character ' '

Notes before: this is updated, and there is a question with the name 'error: database names cannot contain the character '.' but this is with a space or a null character, not a dot! I am not sure if that could be a major difference, but apart from that question, the answer supposed there did not help me further. Also, I use Windows 7 (32 bits (not the best thing for mongodb, I know) and I made the description a bit more detailed).
To the point: I wanted to start meteor again for the first time after a couple of days (everything worked fine before) and suddenly this error appeared:
W20150803-18:44:47.168(2)? (STDERR) C:\Users\Laptop\AppData\Local\.meteor\packag
es\meteor-tool\1.1.3\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fib
ers\future.js:245
W20150803-18:44:47.168(2)? (STDERR)
throw(ex);
W20150803-18:44:47.168(2)? (STDERR)
^
W20150803-18:44:47.168(2)? (STDERR) Error: database names cannot contain the cha
racter ' '
W20150803-18:44:47.169(2)? (STDERR) at validateDatabaseName (C:\Users\Laptop
\AppData\Local\.meteor\packages\mongo\1.1.0\npm\node_modules\mongodb\lib\mongodb
\db.js:235:59)
W20150803-18:44:47.169(2)? (STDERR) at new Db (C:\Users\Laptop\AppData\Local
\.meteor\packages\mongo\1.1.0\npm\node_modules\mongodb\lib\mongodb\db.js:97:3)
W20150803-18:44:47.169(2)? (STDERR) at connectFunction (C:\Users\Laptop\AppD
ata\Local\.meteor\packages\mongo\1.1.0\npm\node_modules\mongodb\lib\mongodb\mong
o_client.js:275:29)
W20150803-18:44:47.169(2)? (STDERR) at Function.MongoClient.connect (C:\User
s\Laptop\AppData\Local\.meteor\packages\mongo\1.1.0\npm\node_modules\mongodb\lib
\mongodb\mongo_client.js:345:5)
W20150803-18:44:47.170(2)? (STDERR) at Function.Db.connect (C:\Users\Laptop\
AppData\Local\.meteor\packages\mongo\1.1.0\npm\node_modules\mongodb\lib\mongodb\
db.js:2094:23)
W20150803-18:44:47.170(2)? (STDERR) at new MongoConnection (packages/mongo/m
ongo_driver.js:173:1)
W20150803-18:44:47.170(2)? (STDERR) at new MongoInternals.RemoteCollectionDr
iver (packages/mongo/remote_collection_driver.js:4:1)...
W20150803-18:44:47.171(2)? (STDERR) at Object.<anonymous> (packages/mongo/re
mote_collection_driver.js:38:1)
W20150803-18:44:47.171(2)? (STDERR) at Object.defaultRemoteCollectionDriver
(packages/underscore/underscore.js:750:1)
W20150803-18:44:47.171(2)? (STDERR) at new Mongo.Collection (packages/mongo/
collection.js:98:1)
A database name being empty while I haven't created any database in the meantime left me in utter darkness since then.
I thought it had to do with one specific project I tried to run (that project already had a load of issues by setting it up, but in the end it worked anyway), but I hadn't changed anything in there, neither did I change any other project. What made me more confused, is that I got this same error on every single other project I have tried to start.
After a while, I rebooted, and the projects started again, but the actual project where all of this began, failed again, this time showing an old known error:
Unexpected mongo exit code 14. Restarting.
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Can't start Mongo server.
MongoDB had an unspecified uncaught exception.
This can be caused by MongoDB being unable to write to a local database.
Check that you have permissions to write to .meteor/local. MongoDB does
not support filesystems like NFS that do not allow file locking.
The original solution to that, was running this in CMD:
"c:\mongodb\bin\mongod.exe" --port 27017 --dbpath "C:\Users\Laptop\TheDatabaseFolder\rs2" --replSet rs2 --smallfiles --setParameter failIndexKeyTooLong=false //note: this had to be done due to 32 bit issue
rs.initiate()
This still gave the same 'cannot write' error although the CMD showed that writing was permitted. Finally I did this:
set MONGO_URL=mongodb://localhost:27017/meteor
Then I fired meteor with a specific config file (due to packages failing to load)
meteor --settings ../config/development/settings.json.dist
And there was the main problem with the database name containing a space or null character again.
In general: what is the most efficient way to get rid of this problem? Why could this have been suddenly sneaking into every project to make them fail? And, where is this 'packages/mongo/collection.js' (in general 'packages/mongo' as such) located anyway? I cannot find it at all...
Thanks in advance.
I would get this error every time I restarted my computer and then tried to make any sort of request. It appears to be something with the favicon.ico file. I'm just using local host to test out API calls so I obviously did not have this file. I'm pretty sure my requests were reading this as a database name, which would have the illegal '.' character. I finally added:
app.get('/favicon.ico', function(req, res) {
res.sendStatus(204);
});
And now everything seems to work again. There is a 204 response for the favicon.ico request every time I put through a request, but it works.

Can't Connect to MongoDB from play app with salat: command failed [listDatabases]

I am trying to get started with the salat plugin in playframework. I have configured the database in application.conf and added all the dependencies to Build.scala and added salat to the play.plugins file. I haven't actually added any code to the project yet, I just followed the instructions on the github page, and then tried to run the project. I am getting the following error message
(Server started, use Ctrl+D to stop and go back to the console...)
[info] play - mongodb [default] connected at heroku_app4620908#ds031907.mongolab.com:31907/heroku_app4620908
[error] application -
! #6bchnaacn - Internal server error, for request [GET /] ->
play.api.Configuration$$anon$1: Configuration error [couldn't connect to [ds031907.mongolab.com/107.21.153.211:31907]]
at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:71) ~[play_2.9.1-2.0.3.jar:2.0.3]
at play.api.Configuration.reportError(Configuration.scala:258) ~[play_2.9.1-2.0.3.jar:2.0.3]
at se.radley.plugin.salat.SalatPlugin$$anonfun$onStart$1.apply(SalatPlugin.scala:105) ~[play-plugins-salat_2.9.1-1.0.8.jar:1.0.8]
at se.radley.plugin.salat.SalatPlugin$$anonfun$onStart$1.apply(SalatPlugin.scala:98) ~[play-plugins-salat_2.9.1-1.0.8.jar:1.0.8]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) ~[scala-library.jar:0.11.3]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) ~[scala-library.jar:0.11.3]
Caused by: com.mongodb.CommandResult$CommandFailure: command failed [listDatabases]: { "serverUsed" : "db-uri" , "errmsg" : "need to login" , "ok" : 0.0}
at com.mongodb.CommandResult.getException(CommandResult.java:88) ~[mongo-java-driver-2.8.0.jar:na
at com.mongodb.CommandResult.throwOnError(CommandResult.java:134) ~[mongo-java-driver-2.8.0.jar:na]
at com.mongodb.Mongo.getDatabaseNames(Mongo.java:356) ~[mongo-java-driver-2.8.0.jar:na]
at com.mongodb.casbah.MongoConnection.getDatabaseNames(MongoConnection.scala:190) ~[casbah-core_2.9.1-2.4.1.jar:2.4.1]
at se.radley.plugin.salat.SalatPlugin$$anonfun$onStart$1.apply(SalatPlugin.scala:103) ~[play-plugins-salat_2.9.1-1.0.8.jar:1.0.8]
at se.radley.plugin.salat.SalatPlugin$$anonfun$onStart$1.apply(SalatPlugin.scala:98) ~[play-plugins-salat_2.9.1-1.0.8.jar:1.0.8]
I am stumped because I added my password and everything to the conf file. From the log it looks as though whatever is trying to connect to the database for me, is not logging in first, using the info I provided.
As you say, it looks like the root issue is that MongoDB is rejecting the command "listDatabases". This command requires administrator access to the MongoDB process since it reveals information about the other databases hosted there.
Unfortunately, the message it returns, "need to login", is a little misleading. You have logged in! You just don't have permission to list the databases.
Here's a simple experiment you can try yourself with the MongoDB shell. See that "show dbs" fails with the same error message you got in your app, but "show collections", which doesn't require access to any other databases outside your own, succeeds?
% mongo ds031907.mongolab.com:31907/heroku_app4620908 -u heroku_app4620908 -p your_password
MongoDB shell version: 2.0.7
connecting to: ds031907.mongolab.com:31907/heroku_app4620908
> show dbs
Fri Aug 17 13:12:10 uncaught exception: listDatabases failed:{ "errmsg" : "need to login", "ok" : 0 }
> show collections
system.indexes
system.users
(Note: I did this with my own MongoLab account and modified the text when copying and pasting here so you could just copy it into your terminal.)
Is there a way to avoid making the listDatabases call? I'm not familiar with the framework you're using.
I've the problem as well...
it should come with the SalatPlugin's onStart method that is requesting all database names: source._2.connection.getDatabaseNames().
This code is just testing the aliveness of the server...
I'm gonna check with leon how we could this differently! Sadly, you won't be able to connect until this will be fixed!
Stay tuned on this issue https://github.com/leon/play-salat/issues/23
This is fixed in the latest version of play-salat, it now uses getCollectionNames instead
use admin
db.addUser('userName', 'userPassword')
db.auth('userName', 'userPassword')
show dbs
java:
DB db = mongo.getDB("YouDBName") ;
db.authenticate("userName", "userPassword".toCharArray()) ;
System.out.println(mongo.getDatabaseNames()) ;

Heroku and mongoHQ: Connection failed

I have the following environment variable on Heroku :
MONGOHQ_URL: mongodb://heroku:password%40mongohq%2Estaff%2Ecom:10056/app6186345
Originally the error was :
Database name cannot contain '.'
I escaped '.' and '#'and I still have the same result, a connection failed but with the message :
[Error: failed to connect to [heroku:27017]]
What am I doing wrong?
When I checked the documentation about mongoHQ, nothing is said about escaping caracters or something equivalent.
It looks like you may have reversed the subdomain and domain name for mongohq on accident.
It should be #staff.mongohq.com instead of #mongohq.staff.com