jdesboeufs / connect-mongo

MongoDB session store for Express
MIT License
1.96k stars 342 forks source link

can't connect with a mongo+srv connection string #368

Closed shaharsol closed 3 years ago

shaharsol commented 4 years ago

Atlas enforces that...

MRVDH commented 3 years ago

Atlas also allows for mongodb:// connection strings. See: https://stackoverflow.com/questions/54986716/node-js-mongoerror-not-authorized-on-admin-to-execute-command/55037826#55037826

gianlucaparadise commented 3 years ago

Is the support to mongodb+srv connection strings planned?

mscomparin commented 3 years ago

I can connect to an atlas db using an existing connection with the native js driver following this guide: https://github.com/jdesboeufs/connect-mongo#connection-to-mongodb

I copied the connection string from the atlas web interface and it follows this form mongodb+srv://user:pass@clustername.mongodb.net/test?retryWrites=true&w=majority (private details edited)

If you already use mongo for other things you can probably do this.

IzaGz commented 3 years ago

I have tried that mentioned in @MRVDH advise, but still not working, any help? with 'mongodb+srv:// string type getting error (node:16402) UnhandledPromiseRejectionWarning: MongoError: (Unauthorized) not authorized on admin to execute command { insert: "system.indexes", documents: [[{ns admin.sessions} {key [{expires 1}]} {name expires_1} {expireAfterSeconds 0} {unique false}]], ordered: true, writeConcern: { w: "majority" } }

With string as in advise getting err = new MongoError(options); ^ MongoError: connection 0 to MONGO_ATLAS_CONNECTION_URL Any help?

mingchuno commented 3 years ago

@IzaGz @shaharsol I have just rewrite the code using TS and published a new version! Can you please help me try it out to see of it fix your issue? https://www.npmjs.com/package/connect-mongo