1

I've deployed my own MongoDB cluster. I've a running Meteor application which is running with Phusion Passenger on the top of Nginx. I'm getting following error after updating the connection string in Nginx configuration file:

/<app_directory>/bundle/programs/server/node_modules/fibers/future.js:280
                                                throw(ex);
                                                ^

Error: missing delimiting slash between hosts and options
    at module.exports (/<app_directory>bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/url_parser.js:37:11)
    at connect (/<app_directory>/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:289:16)
    at Function.MongoClient.connect (/<app_directory>/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:113:3)
    at new MongoConnection (packages/mongo/mongo_driver.js:175:11)
    at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)
    at Object.&lt;anonymous&gt; (packages/mongo/remote_collection_driver.js:38:10)
    at Object.defaultRemoteCollectionDriver (packages/underscore.js:784:19)
    at new Mongo.Collection (packages/mongo/collection.js:99:40)
    at AccountsServer.AccountsCommon (packages/accounts-base/accounts_common.js:23:18)
    at new AccountsServer (packages/accounts-base/accounts_server.js:18:5)

The application was running fine when the connection string was in following format previously:

passenger_env_var MONGO_URL mongodb://db_user:db_password@host_name:port_no/db_name;

But it starts showing error when I try to connect to mu mongoDB cluster by updating connection string in following way:

passenger_env_var MONGO_URL mongodb://db_user:'password_with_special_character'@host1_name:port_no,host2_name:port_no/db_name?replicaSet=replica_set_name;

Is there anything wrong in the connection string or any other problem?

Mostafiz Rahman
  • 8,169
  • 7
  • 57
  • 74
  • 1
    So it also does not run even when escaping that special character? Also the string are 86 charaters and the new one 156 characters long. Is there maybe a line length restricted to something between those values? – Jankapunkt Dec 14 '17 at 16:51
  • Haven't tried escaping that special character. The same connection string is working in another VM with PM2, but not working with Phusion Passanger – Mostafiz Rahman Dec 14 '17 at 16:53
  • @Jankapunkt I've just removed special characters from the password and it worked! – Mostafiz Rahman Dec 15 '17 at 12:32

1 Answers1

2

This is not an issue with Passenger, it just passes on the string as you configure it. Usually you would enclose the entire string with quotes like:

passenger_env_var MONGO_URL 'mongodb://db_user:password_with_special_character@host1_name:port_no,host2_name:port_no/db_name?replicaSet=replica_set_name;'

The problem is that the Mongo client needs to understand the string, which means you need to use an escaping mechanism that it supports, such as URL encoding. For example, if the password contains a @, you can URL encode that with %40:

# password = p@ssword, @ = url encoded as %40
passenger_env_var MONGO_URL 'mongodb://username:p%40ssword@host:port/dbname';

You can see the default URL encodings for other special characters here.

OnixSO
  • 136
  • 2