Hi, I need to host my bot which requires a MongoDB, I am using atlas for that, but I don’t know how to connect it. Please help
I am getting this error: https://del.dog/tewognymet
go to atlas and head to ‘network access’ under the security tab on the left.
If you haven’t already, make sure to add the ip 0.0.0.0/0 or click ‘allow access for everyone’
make sure you have the right credentials linked in your address, if you need to make a new user do so.
If you need guidance then click ‘connect’ on your cluster to get step by step instructions
I did that but I am getting this again: (node:5136) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor. (node:5136) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [gamespeck-shard-00-00-x4aoz.gcp.mongodb.net:27017] on first connect [MongoError: bad auth Authentication failed.] at Pool.<anonymous> (/rbd/pnpm-volume/45d7f176-e58e-4830-8df1-28b69ccaf2ea/node_modules/.registry.npmjs.org/mongodb/3.5.6/node_modules/mongodb/lib/core/topologies/server.js:438:11) at Pool.emit (events.js:189:13) at createConnection (/rbd/pnpm-volume/45d7f176-e58e-4830-8df1-28b69ccaf2ea/node_modules/.registry.npmjs.org/mongodb/3.5.6/node_modules/mongodb/lib/core/connection/pool.js:561:14) at connect (/rbd/pnpm-volume/45d7f176-e58e-4830-8df1-28b69ccaf2ea/node_modules/.registry.npmjs.org/mongodb/3.5.6/node_modules/mongodb/lib/core/connection/pool.js:1008:9) at callback (/rbd/pnpm-volume/45d7f176-e58e-4830-8df1-28b69ccaf2ea/node_modules/.registry.npmjs.org/mongodb/3.5.6/node_modules/mongodb/lib/core/connection/connect.js:97:5) at provider.auth.err (/rbd/pnpm-volume/45d7f176-e58e-4830-8df1-28b69ccaf2ea/node_modules/.registry.npmjs.org/mongodb/3.5.6/node_modules/mongodb/lib/core/connection/connect.js:396:21) at _authenticateSingleConnection (/rbd/pnpm-volume/45d7f176-e58e-4830-8df1-28b69ccaf2ea/node_modules/.registry.npmjs.org/mongodb/3.5.6/node_modules/mongodb/lib/core/auth/auth_provider.js:66:11) at sendAuthCommand (/rbd/pnpm-volume/45d7f176-e58e-4830-8df1-28b69ccaf2ea/node_modules/.registry.npmjs.org/mongodb/3.5.6/node_modules/mongodb/lib/core/auth/scram.js:240:11) at _callback (/rbd/pnpm-volume/45d7f176-e58e-4830-8df1-28b69ccaf2ea/node_modules/.registry.npmjs.org/mongodb/3.5.6/node_modules/mongodb/lib/core/connection/connect.js:349:5) at Connection.messageHandler (/rbd/pnpm-volume/45d7f176-e58e-4830-8df1-28b69ccaf2ea/node_modules/.registry.npmjs.org/mongodb/3.5.6/node_modules/mongodb/lib/core/connection/connect.js:378:5) at Connection.emit (events.js:189:13) at processMessage (/rbd/pnpm-volume/45d7f176-e58e-4830-8df1-28b69ccaf2ea/node_modules/.registry.npmjs.org/mongodb/3.5.6/node_modules/mongodb/lib/core/connection/connection.js:384:10) at TLSSocket.<anonymous> (/rbd/pnpm-volume/45d7f176-e58e-4830-8df1-28b69ccaf2ea/node_modules/.registry.npmjs.org/mongodb/3.5.6/node_modules/mongodb/lib/core/connection/connection.js:553:15) at TLSSocket.emit (events.js:189:13) at addChunk (_stream_readable.js:284:12) at readableAddChunk (_stream_readable.js:265:11) (node:5136) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:5136) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:5136) UnhandledPromiseRejectionWarning: Error: 400: Bad Request: wrong message entity: Wrong HTTP URL at buildConfig.then.then.then.then (/rbd/pnpm-volume/45d7f176-e58e-4830-8df1-28b69ccaf2ea/node_modules/.registry.npmjs.org/telegraf/3.38.0/node_modules/telegraf/core/network/client.js:281:17) at process._tickCallback (internal/process/next_tick.js:68:7) (node:5136) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:5136) UnhandledPromiseRejectionWarning: Error: 400: Bad Request: wrong message entity: Wrong HTTP URL at buildConfig.then.then.then.then (/rbd/pnpm-volume/45d7f176-e58e-4830-8df1-28b69ccaf2ea/node_modules/.registry.npmjs.org/telegraf/3.38.0/node_modules/telegraf/core/network/client.js:281:17) at process._tickCallback (internal/process/next_tick.js:68:7) (node:5136) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
does your URL begin with mongodb+srv:// ?
goto connect / connect your application then copy the full URL substituting your password
yes, it does. should I remove +srv?
no, from what I know it has to be:
- incorrect password
- ip not whitelisted
-
CHECK your password and username in your URL, remember to replace
<password>
with your password for that cluster -
remember to whitelist all addresses! if you don’t do this then you cannot connect
and is your cluster ready? prepared for all connections?
do i have to put my password inside <>? Because I did that
@Daksh777 here is a bit of code:
replace
mongoose.connect(keys.mongoURI);
with
mongoose.connect(keys.mongoURI, () => { }, { useNewUrlParser: true })
.catch(err => {
console.log(err);
});
no you replace the <> with your password
Thanks a lot! It worked!
happy to help! I have several clusters setup myself
It still doesn’t show active connections as 1 but the console logged the DB connected message
And the bot too works
Edit: had to refresh to show
just a question, are your credentials in .env?
Yes, they are. It seems safer to me
okay, just if you don’t keep them in a .env then you risk damage to your cluster (if thats possible)
Oh, how is that possible?
well, on the free plan you only get so much space and memory. Perhaps somebody could connect to the cluster and spam with requests so your CPU goes crazy, or spam your databases.
But the chances of that happening are very low
Oh okay, thanks for the info. I will keep that in mind