-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 4.11.0
-
Component/s: Deno
What problem are you facing?
As a Deno user, I can now use MongoDB's official driver. The issue is that, even though I can locally connect to MongoDB instances, it's not currently possible for me to connect to MongoDB Cloud instances.
The issue can be divided into two parts:
- DNS Resolves work differently between Node and Deno. The latter will return records as is (with a trailing dot). This is by far, the easiest one to fix. I was able to work around it by mapping the response of `dns.promises.resolveSrv` on `src/connection_string.ts:83`, with an easy fix:
const addresses = (await dns.promises.resolveSrv(
`_${options.srvServiceName}._tcp.${lookupAddress}`
))
.map((address) => ({
...address,
name: address.name.replace(/\.$/, '')
}));
- I haven't been able to track the possible cause for this issue: I'm getting an error trying to connect to the server replica, getting as a result an error message similar to this one:
MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/ at NativeConnection.Connection.openUri (file:///Users/pandres95/Library/Caches/deno/npm/registry.npmjs.org/mongoose/6.7.0/lib/connection.js:824:32) at file:///Users/pandres95/Library/Caches/deno/npm/registry.npmjs.org/mongoose/6.7.0/lib/index.js:417:10 at file:///Users/pandres95/Library/Caches/deno/npm/registry.npmjs.org/mongoose/6.7.0/lib/helpers/promiseOrCallback.js:41:5 at new Promise (<anonymous>) at promiseOrCallback (file:///Users/pandres95/Library/Caches/deno/npm/registry.npmjs.org/mongoose/6.7.0/lib/helpers/promiseOrCallback.js:40:10) at Mongoose._promiseOrCallback (file:///Users/pandres95/Library/Caches/deno/npm/registry.npmjs.org/mongoose/6.7.0/lib/index.js:1270:10) at Mongoose.connect (file:///Users/pandres95/Library/Caches/deno/npm/registry.npmjs.org/mongoose/6.7.0/lib/index.js:416:20) at Function.connection (file:///Users/pandres95/Documents/Bloque/Development/Projects/Services/microservices/services/swap/src/infrastructure/repositories/mongo/mongoose.database.ts:12:36) at Function.get instance (file:///Users/pandres95/Documents/Bloque/Development/Projects/Services/microservices/services/swap/src/infrastructure/repositories/mongo/mongoose.database.ts:8:17) at file:///Users/pandres95/Documents/Bloque/Development/Projects/Services/microservices/services/swap/src/infrastructure/server/mod.ts:26:42 MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/ at NativeConnection.Connection.openUri (file:///Users/pandres95/Library/Caches/deno/npm/registry.npmjs.org/mongoose/6.7.0/lib/connection.js:824:32) at file:///Users/pandres95/Library/Caches/deno/npm/registry.npmjs.org/mongoose/6.7.0/lib/index.js:417:10 at file:///Users/pandres95/Library/Caches/deno/npm/registry.npmjs.org/mongoose/6.7.0/lib/helpers/promiseOrCallback.js:41:5 at new Promise (<anonymous>) at promiseOrCallback (file:///Users/pandres95/Library/Caches/deno/npm/registry.npmjs.org/mongoose/6.7.0/lib/helpers/promiseOrCallback.js:40:10) at Mongoose._promiseOrCallback (file:///Users/pandres95/Library/Caches/deno/npm/registry.npmjs.org/mongoose/6.7.0/lib/index.js:1270:10) at Mongoose.connect (file:///Users/pandres95/Library/Caches/deno/npm/registry.npmjs.org/mongoose/6.7.0/lib/index.js:416:20) at Function.connection (file:///Users/pandres95/Documents/Bloque/Development/Projects/Services/microservices/services/swap/src/infrastructure/repositories/mongo/mongoose.database.ts:12:36) at Function.get instance (file:///Users/pandres95/Documents/Bloque/Development/Projects/Services/microservices/services/swap/src/infrastructure/repositories/mongo/mongoose.database.ts:8:17) at file:///Users/pandres95/Documents/Bloque/Development/Projects/Services/microservices/services/swap/src/infrastructure/server/mod.ts:26:42
What driver and relevant dependency versions are you using?
MongoDB Driver:
npm:mongodb@4.11.0
Deno:
v1.27.0
Steps to reproduce?
Create an application on Deno, importing dependencies from `npm:mongodb`, and try to connect to any Atlas server using the `mongodb+srv` protocol.
- is related to
-
NODE-5042 Relax SRV record validation to account for a "." suffix
- Closed