Connect to MONGOS via mongoose

468 views
Skip to first unread message

Jim Largent

unread,
Oct 12, 2017, 11:13:27 AM10/12/17
to mongodb-user
I have an MEAN stack application that, of course, connects to mongo using the mongoose library.  Using a single stand-alone mongodb server works just fine and has been working for over a year.  The data is expanding so we're prototyping a sharded cluster.  I thought all that would be needed was to point the connection string to the new MONGOS instance and everything would be transparent to the application.  Not the case.  Changing only the hostname/port to connect to the new interface get the following response (the actual hostname and port are not shown):
MongoError: connection 0 to <hostname>:<port> closed
TypeError: path must be a string


Poking around the documentation, I see an option for mongos: true.  The documentation implies this is needed for a multiple connection for mongos, but I tried it and got:
MongoError: no mongos proxy available
TypeError: path must be string


As helpful and  descriptive as these error messages are, I just don't understand why this isn't a simple change.

Here are the versions:
Mongoose: 4.10.2
Node js: .10
Mongodb: 3.4.2

Yes, that's dot 10 of node js.  I came onto the project after it was underway and updating node just hasn't been a priority. 

I'm willing to update node, but not just to see what happens.  If someone has some knowledge of the mongoose connection internals that might help debug or solve the problem, I'd greatly appreciate it. The authentication is using X509 certs.

Thanks

Kevin Adistambha

unread,
Oct 17, 2017, 9:26:28 PM10/17/17
to mongodb-user

Hi Jim

I tried switching back and forth between a standalone mongod and a sharded cluster and so far found that no changes are necessary to the connection string, as expected. Mongoose will also insert into a sharded collection with no issue.

Could you post a small script that could reproduce the error? It will also be helpful to know how your MongoDB sharded cluster is setup (e.g. config files content, command line options, etc.). Without those information, there is little anyone can do to try to reproduce this.

You might also consider posting the issue in the Mongoose github project to see if anyone is having a similar issue.

Best regards
Kevin

Reply all
Reply to author
Forward
0 new messages