mongo icon indicating copy to clipboard operation
mongo copied to clipboard

feat: support atlas shared cluster

Open nyxb opened this issue 3 years ago • 10 comments

Database conected right after a short time get error error:

Uncaught (in promise) Error: MongoError: "Invalid response header" if (!headerBuffer) throw new MongoDriverError("Invalid response header");
                               ^
at WireProtocol.receive (https://deno.land/x/[email protected]/src/protocol/protocol.ts:106:32)

I connect with srv url

my code

import { MongoClient } from "https://deno.land/x/[email protected]/mod.ts";
import { logger } from "../utils/logger.ts";
import { configs } from "../../configs.ts";

const log = logger({ name: "DB Manager" });

log.info("Initializing Database 👀");

const client = new MongoClient();
const db = configs.DATABASE;

client.connect(
  "mongodb+srv://vidar:[][email protected]/DiscordenoBot?authMechanism=SCRAM-SHA-1"
);

log.info("Database connected successfully ✅");

Normally the srv url is in env. if i produce the same on node i get no error

nyxb avatar Feb 27 '22 08:02 nyxb

Hm yeah we have some trouble with MongoDB Atlas

lucsoft avatar Feb 27 '22 09:02 lucsoft

So hope it goes in few times need it. pls inform me here if it fixed.

nyxb avatar Feb 27 '22 09:02 nyxb

Which MongoDB atlas service do you use? https://mongo-demo.deno.dev/ works fine with M0 free tier

erfanium avatar Feb 27 '22 09:02 erfanium

Which MongoDB atlas service do you use? https://mongo-demo.deno.dev/ works fine with M0 free tier

I told it in my Post it's MongoDB Atlas https://www.mongodb.com/atlas/database

nyxb avatar Feb 27 '22 09:02 nyxb

@VidarDev MongoDB Atlas has many different clusters. like serverless clusters, dedicated clusters and shared clusters. I can confirm there's not problem with fee M0 tier of dedicated cluster. Also we know serverless clusters are not supported yet.

So make sure you created a dedicated M0 cluster with default options

erfanium avatar Feb 27 '22 10:02 erfanium

@erfanium

i have a M0 shared Cluster

So I can use shared for free, dedicated not. is shared supported?

N22H95W

mine is hosted in the cloud. And not locally. Can this be the problem?

nyxb avatar Feb 27 '22 10:02 nyxb

ok now i generate a cluster local and not cloud and it goes.

So any ATA for use clouded and serverless?

nyxb avatar Feb 27 '22 10:02 nyxb

why did you close it? we should improve our atlas support

lucsoft avatar Feb 27 '22 12:02 lucsoft

sry didnt want close it 🙈

nyxb avatar Feb 27 '22 12:02 nyxb

Hm yeah we have some trouble with MongoDB Atlas

@VidarDev I recommend you to use the object version it is faster than srv url:

await client.connect({
    db: "<db_name>",
    tls: true,
    servers: [
    /* 
         You can pass the 3 shared cluster url, just copy and paste the object below
        three times and edit every single cluster url.
    */
    {
      host: "<db_cluster_url>",
      port: 27017,
    },
  ],
  credential: {
    username: "<username>",
    password: "<password>",
    db: "<db_name>",
    mechanism: "SCRAM-SHA-1",
  },
});

If, we connect to Atlas DB using srv url, it will take too long but we can use the general cluster url generated by mongodb Atlas.

Pd. Sorry by my English, I am learning. 🖖🏻

diecodev avatar Jul 05 '22 07:07 diecodev