mongo
mongo copied to clipboard
feat: support atlas shared cluster
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
Hm yeah we have some trouble with MongoDB Atlas
So hope it goes in few times need it. pls inform me here if it fixed.
Which MongoDB atlas service do you use? https://mongo-demo.deno.dev/ works fine with M0 free tier
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
@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
i have a M0 shared Cluster
So I can use shared for free, dedicated not. is shared supported?

mine is hosted in the cloud. And not locally. Can this be the problem?
ok now i generate a cluster local and not cloud and it goes.
So any ATA for use clouded and serverless?
why did you close it? we should improve our atlas support
sry didnt want close it 🙈
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. 🖖🏻