Can't connect from Nodejs to Atlas Serverless

Hi dear community,

I need some help. I’m trying to connect to an Atlas Serverless database from Nodejs. It just won’t work. Tried and triple checked everything I found. mongosh connect works, so user/passwd must be right, and ip whitelisting must work too. Did http://portquiz.net:27017.

I followed https://www.mongodb.com/developer/how-to/atlas-serverless-quick-start/ to the letter, yet the insertOne fails with “MongoDriverError: MongoClient must be connected to perform this operation”.

Help please! <3

Cheers,
inki

2 Likes

Hi Inki,

Thank you for pointing this out. We are working on a fix for the Node.js driver and hope to have this complete in the next couple of days. We’ll update here when the updated driver is released.

For now, the python and java drivers, and mongosh should all be compatible.

Thanks,
Jesse

1 Like

Also how about php driver for connect ?

1 Like

Hi @Sky_Team, currently the PHP driver is not yet supported. Here is a list of supported drivers: https://docs.atlas.mongodb.com/reference/serverless-instance-limitations/#minimum-driver-versions-for-serverless-instances

We are working hard to add more support very soon!

2 Likes

Hello @Jesse_Hall,
sorry but i am quite confused. In the link that you post is wrote that NodeJS is not supported, but then I found this:

And I tried to connect with Mongoose and it give me an error:
MongoDB disconnected!
Error in MongoDb connection: MongoParseError: Text record must only set `authSource` or `replicaSet`
(node:9708) UnhandledPromiseRejectionWarning: MongoParseError: Text record must only set `authSource` or `replicaSet`
    at QueryReqWrap.callback (T:\Lavori_Software\k-core\node_modules\mongodb\lib\core\uri_parser.js:111:13)
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:205:10)
(node:9708) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9708) [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.

Please can you clarify the situation? Is it supported or not NodeJS/Mongoose? If not, do you have an idea bout when it could be supported?

Thanks a lot

The Node.js drivers have been updated and are now working on Atlas serverless instances! :tada:

Please be sure to use v4.1.0 or higher.

2 Likes

Thanks. But I still have the same problem, and I used this software with Free instance of Mongo and it work perfectly. Can you help me to find why it doesn’t work? Thanks

Hi @KILAB_Cloud,

I’m not sure which driver version mongoose is using, but you will need to be sure to use mongodb v4.1.0 or higher to work with serverless instances.

Thanks actualy mongoose use version 3.6.10:
default-microservice-anager@1.0.0 T:\Lavori_Software\k-core
-- mongoose@5.13.5 – mongodb@3.6.10

So I have o wait until Mongoose update to version 4.1.0 (soon I hope)

Thanks for the help

1 Like

how about php driver ?

Hi @Sky_Team, currently the PHP driver is not yet supported. Here is a list of supported drivers: https://docs.atlas.mongodb.com/reference/serverless-instance-limitations/#minimum-driver-versions-for-serverless-instances

We are working hard to add more support very soon!

2 Likes

@Jesse_Hall Hi! According to the link you posted the Node Js is supported now? In the “Connect” tab in the console, it is shown as unsupported so far. What is the status of Node Js support now?

Hi @workreactor, Node.js v4.1.0+ is now supported. I will look into the “connect” tab documentation. Thank you for pointing that out!

2 Likes

Hi

I am using mongoose - v5.11.16 . And I am still getting the error
MongoParseError: Text record must only set authSource or replicaSet .

Can you help here

Thanks
Preveen

Hi @Knowledge_Store,

What MongoDB driver are you using? v4.1.0 or greater is required.

Thank you,
Jesse

Looks like Mongoose is using 3.6.10 MongoDB Driver. Any plan to support 3.6.10 in Atlas Serverless in the neat future

Hello, next release of mongoose 6.0 now in RC1 will use Mongodb 4.1.0
we have just to wait a bit :slight_smile:

1 Like

Ok, thank you ! for the quick response

1 Like

I had the same issue and ended up here. I’ve tested and can confirm that mongoose 6.0.0 rc-1 works with Atlas Serverless.

npm i mongoose@6.0.0-rc1

Thanks @Jesse_Hal for your support on this.

2 Likes

Thank you for the update @Michael_Antoniades! That is very helpful :smiley: