node-red-tools / node-red-contrib-mongodb

MongoDB for Node-Red
MIT License
2 stars 1 forks source link

Provide a working example for MongoDb Atlas #18

Closed UNOPARATOR closed 4 years ago

UNOPARATOR commented 4 years ago

Please provide a working example configuration for using your node with a MongoDb Atlas connection. I tried everything that I could think of but nothing was successful.

ziflex commented 4 years ago

Hey, I haven't used this plugin with MongoDB Atlas. What issues are you experiencing ?

UNOPARATOR commented 4 years ago

MongoDb Atlas gives me this connection string which I can use with MongoDb Compass without any problems:

mongodb+srv://loader:<pasword>@my_hidden_host_name.azure.mongodb.net/testDB?authSource=admin&retryWrites=true&w=majority

Here is my mongodb-config node info: image image I tried with and without specifying options image

And here is my collection node info: image This is the error message shown in debug window:

MongoServerSelectionError: getaddrinfo ENOTFOUND my_hidden_host_name.azure.mongodb.net my_hidden_host_name.azure.mongodb.net:27017 at Timeout.waitQueueMember.timer.setTimeout [as _onTimeout] (/data/node_modules/mongodb/lib/core/sdam/topology.js:430:30) at ontimeout (timers.js:436:11) at tryOnTimeout (timers.js:300:5) at listOnTimeout (timers.js:263:5) at Timer.processTimers (timers.js:223:10)

ziflex commented 4 years ago

I think mongodb+srv:// this is the key. We need to add a support of it as it says here. Could you make a small change in your local copy of the package? Replace mongodb:// with just mongo right here and update your connection string accordingly.

UNOPARATOR commented 4 years ago

That doesn't work either (even if I replace mongodb:// with mongo://), but changing the mongodb:// with mongodb+srv:// does work.

You might take the following as a suggestion or not, it is up to you: I think you'll need to handle both cases in your code, or toggle +srv with a checkbox or something. Alternatively you might give an option to set the connection either via a connection string textbox or via seperate input controls (just like now). Just my two cents.

P.S: You can always create a free (M0 tier) MongoDb Atlas instance to test it further. ;)

ziflex commented 4 years ago

@UNOPARATOR hey, can you try this fix to make sure it solved your problem? https://github.com/node-red-tools/node-red-contrib-mongodb/tree/bugfix/%2318-atlas

UNOPARATOR commented 4 years ago

I converted the settings.ts file to settings.js using an online converter then restarted my Node-RED instance. It works, thank you 💯

ziflex commented 4 years ago

Published a new 1.3.0 version .

UNOPARATOR commented 4 years ago

Just a heads up, it is still not showing up on Node-RED's site or as an update in Node-RED's admin ui.

ziflex commented 4 years ago

It is now. Seems there is a delay.

UNOPARATOR commented 4 years ago

Another just a heads up. ;) Unfortunately after all this time, it still shows the v1.2.0 as the latest version at https://flows.nodered.org/node/@node-red-tools/node-red-contrib-mongodb , which makes it impossible to update using the "Manage palette" menu. image Since I've changed the relevant manually in my installation, I don't have an issue at the moment. By the way, if I follow the link "view on npm" I can see the v1.3.0 there; the problem resides at Node-RED's side.

ziflex commented 4 years ago

I forgot to push 1.3.0 release 🤦‍♂️

UNOPARATOR commented 4 years ago

I guess you still haven't pushed the button yet. Because after another month, it still shows the v1.2.0 as the latest version at https://flows.nodered.org/node/@node-red-tools/node-red-contrib-mongodb , which makes it impossible to update using the "Manage palette" menu. :(

echoix commented 4 years ago

Since April 2020, they can't update the flows from the npm. You need to login the flows.nodered.org and press "Request refresh", or just resubmit it.... https://discourse.nodered.org/t/how-to-add-update-nodes-to-the-flow-library/25294

echoix commented 4 years ago

Looks like anyone connected with their Github account can request a refresh, I did it a couple minutes ago and seems bumped to 1.3.0! image

UNOPARATOR commented 4 years ago

Thank you @echoix . I would have never guessed loging in to Node-RED with my github account to be able to "request refresh".