Sails.js connect to Cloud mongoDb Atlas - javascript

I created a Sails.js app, it connects to local MongoDB correctly but if I want to connect it to cloud mongodb, Sails throws an error. what should I do to fix it?
default: {
adapter: 'sails-mongo',
// url: 'mongodb://localhost:27017/referral' // this work fine
url: 'mongodb+srv://MYUSERNAME:MYPASS#cluster0.ikncs.mongodb.net/referral?retryWrites=true&w=majority'
},
error:
error: A hook (orm) failed to load!
error: Could not tear down the ORM hook. Error details: Error: Consistency violation: Attempting to tear down a datastore (default) which is not currently registered with this adapter. This is usually due to a race condition in userland code (e.g. attempting to tear down the same ORM instance more than once), or it could be due to a bug in this adapter.
error: Error: Invalid configuration for datastore default: Provided URL ('mongodb+srv://MYUSERNAME:MYPASS#cluster0.ikncs.mongodb.net/referral?retryWrites=true&w=majority') has an invalid protocol.
If included, the protocol must be "mongodb://".
I will appreciate if someone help quickly

I had a similar issue.
The connection string I got from Atlas was for Node version 3.0 or later did not work with the sails adapter.
But the connection string from Atlas for Node version 2.2.12 worked.
From Atlas, click connect -> Connect to your application (using MongoDB's Native Drivers) -> Select Node.js Version 2.2.12 or later. Use the connection string it provides.

I have got the same issue, it’s due to mongodb version used in sails-mongo, for our production database we have worked on improving the existing package.
You can search for sails-mongo-cloud in npm which supports cloud mongo atlas and cluster with server less setup as well.

Related

SailsJS connection with Azure MS SQL Database

I installed the latest version of Sails on my computer and created a new project.
I am using SailsJS as my API and want to connect to the clients' Azure MS SQL database.
I tried using the mssql npm package, even the MS SQL adaptor listed on the Sails documents site, but non of these are working.
With mssql I get the following error when running sails lift in the terminal:
` info: Starting app...
error: A hook (orm) failed to load!
error:
error: Error: Consistency violation: the adapter for datastore default does not have an identity property.
at validateDatastoreConfig`
Any guidance will be appreciated...

routing error connecting from javascript lambda function to neo4j 4.4.x via vpc peering

We are in the process of upgrading our Neo4j database from 3.5.28 to 4.4.8 and we've encountered a problem we can't resolve.
Our current platform involves javascript lambda functions accessing a 3.5.28 cluster hosted in a separate VPC using the 1.7.2 javascript driver via a VPC peering connection. This has worked fine for many years.
Now that we're trying to upgrade to the 4.x driver (currently 4.4.6) and a 4.4.8 Neo4j cluster, with the same VPC peering setup, we're getting the following error:
Error registering acceptance of terms: Neo4jError: Could not perform discovery. No routing servers available. Known routing table: RoutingTable[database=default database, expirationTime=0, currentTime=1659054032636, routers=[], readers=[], writers=[]]
We are able to connect to the cluster from the browser app via a VPN gateway in the remote VPC and successfully retrieve the routing table, so it would appear that the cluster itself is working ok.
Has anyone else encountered this problem and hopefully resolved it?

Prism V2 access denied to postgres database

I have created a brand new nodejs project with Prism2 and Postgres 13
Postgres is on a windows VM in the same network. Im testing Prism for the first time and cannot get it to deploy the database schema at all. I cant find anything that tells me how to fix this problem.
When i run npx prisma migrate dev all i get is Error: P1010: User 'johndoe' was denied access on the database 'db.public'. Ive searched for this error message and cant find any resolution, what is the issue here?
Actually the problem was resolved with some changes to the Postgres config files. By default its only listening to the local IP address of the machine that its installed on. With help from this post i was able to resolve the issue.
Made sure that the postgresql.conf listen_addresses was set to '*'. This was correct by default.
Made sure the pg_hba.conf IPv4 host was set within the range of my network. This was changed from host all all 127.0.0.1/32 to host all all 192.168.1.1/24
Restart the postgres service and now everything works as expected.
It's a bug in prisma library itself, has been reported and acknowledged. You can checkout the exact issue here

Feathers JS Client Timeout

I am sure this is something very simple, but for some reason I am getting a timeout when trying to integrate the feathersjs client with a very simple jQuery app. Files of interest are in src below. This repo only contains a single service "messages" connected to a NedB database with no authentication. When the script starts, I am attempting to add a single message to my messages service.
Repo:
https://github.com/Ryan8765/jquery-chat
Error in Console:
Uncaught (in promise) Error: Timeout of 5000ms exceeded calling create on messages
at client.js:66
The server side application has been created with an old (v2) version of the CLI but you are loading #feathersjs/feathers#^3.0.0 in the browser which uses a Socket.io message format that is not supported by a v2 server.
feathers --version on the command line should show 3.3.0 or later. You can either follow the migration guide to upgrade or install the latest #feathersjs/cli and regenerate the application.
Reference issue feathersjs/feathers#761.
I had the same issue using these package's on the client side with vue.js (vue#^3.2.16 and vite#2.6.4)
#feathersjs/feathers#^4.5.11
#feathersjs/socketio-client#^4.5.11
socket.io-client#^2.3.1
#feathersjs/authentication-client#^4.5.11
My issue was resolved after changing
import io from "socket.io-client";
to
import io from "socket.io-client/dist/socket.io";
in my client feathersjs settings

Fail to connect Mongolab with MongodbShell

I'm trying to connect the Mongo shell with Mongolab. I am using my mongolab username and password but it is giving an error: "Failed to connect to 54.81.180.188:56789."
My userName and password is correct.
I'm using Windows 8.1
When I ping ds0-----.mongolab.com that's working fine.
C:\mongodb\bin>mongo ds0----.mongolab.com:56789/dbname -u "MyUserName" -p "MyPassword"
MongoDB shell version: 3.0.3
connecting to: ds027751.mongolab.com:56789/dbname
2015-06-05T10:55:30.019+0530 W NETWORK Failed to connect to 54.81.180.188:56789, reason: errno:10061 No connection could be made because the target machine actively refused it.
2015-06-05T10:55:30.024+0530 E QUERY Error: couldn't connect to server ds027751.mongolab.com:56789 (54.81.180.188), connection attempt failed
at connect (src/mongo/shell/mongo.js:181:14)
at (connect):1:6 at src/mongo/shell/mongo.js:181
exception: connect failed
I had the same problem, my server abruptly lost the ability to connect to MongoLab. I contacted support, who sent this reply:
Hello,
Your Experimental Sandbox plan is running MongoDB 3.0.x, which
includes changes to Mongo's authentication mechanism. This new
mechanism is supported by certain newer driver versions, as described
at
http://docs.mongodb.org/manual/release-notes/3.0-scram/#upgrade-drivers.
To connect to this database, you will need to use one of the drivers
listed at the above link.
Please let us know if you have questions about this.
Sincerely, Samson
I assume I was upgraded automatically, as I hadn't touched the server code or MongoLab in months. As an immediate fix, I just created a new db in MongoLab, which was created in mongod v2.6.9 (I don't remember seeing an option to choose the version).

Categories