Login failed while connecting to SQL Server database from Cube js - node.js

This is the issue I see in the terminal while i run
npm run dev
I am trying to connect to a SQL Server database. I have changed some settings for my user 'sjeswara' using SSMS which might facilitates connection:
Under securities -> Login I have set login as "enabled" for my user.
Under security of database property the setting "SQL Server and Window Authentication" property is also checked.
But this doesn't seem to solve the problem.
ConnectionError: Login failed for user 'sjeswara'.
at Connection. (D:\project\cube\testproj\node_modules\mssql\lib\tedious\connection-pool.js:68:17)
at Object.onceWrapper (events.js:422:26)
at Connection.emit (events.js:315:20)
at Connection.message (D:\project\cube\testproj\node_modules\tedious\lib\connection.js:2148:18)
at Connection.dispatchEvent (D:\project\cube\testproj\node_modules\tedious\lib\connection.js:1279:15)
at MessageIO. (D:\project\cube\testproj\node_modules\tedious\lib\connection.js:1139:14)
at MessageIO.emit (events.js:315:20)
at Message. (D:\project\cube\testproj\node_modules\tedious\lib\message-io.js:46:14)
at Message.emit (events.js:327:22)
at endReadableNT (D:\project\cube\testproj\node_modules\tedious\node_modules\readable-stream\lib_stream_readable.js:1094:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)

Related

cannot connect to SQLExpress usign node.js

I am using SQL Server (SQL EXPRESS) 2005 9.0.3042
I have poured through lots of examples.
Made sure TCP port 1433 open for all IP.
Made sure browser is started
Tried all kinds of config settings
using tedious or mssql
Just trying to find something that will work !!
But all I get is the following errors
ConnectionError: Failed to connect to localhost:1433 - Cannot call write after a stream was destroyed
at ConnectionError (C:\git\adv_energy\sql_node_js\node_modules\tedious\lib\errors.js:13:12)
at Connection.socketError (C:\git\adv_energy\sql_node_js\node_modules\tedious\lib\connection.js:1628:56)
at Socket.<anonymous> (C:\git\adv_energy\sql_node_js\node_modules\tedious\lib\connection.js:1395:14)
at Socket.emit (events.js:327:22)
at errorOrDestroy (internal/streams/destroy.js:108:12)
at onwriteError (_stream_writable.js:418:5)
at onwrite (_stream_writable.js:445:5)
at doWrite (_stream_writable.js:399:11)
at writeOrBuffer (_stream_writable.js:387:5)
at Socket.Writable.write (_stream_writable.js:318:11) {
code: 'ESOCKET'
}

MongoNetworkError : failed to connect to server

First time working with mongoDb inside a Node.js app (using mLab) but i'm unable to connect.
Same exact code works just fine if i try to connect to mongoDB Atlas.
// not working with mLab link and credentials
mongoose.connect(mLabConnectionString)
.then(success => console.log(success))
.catch(error => console.log(error))
// working with atlas link and credentials
mongoose.connect(atlasConnectionString)
.then(success => console.log(success))
.catch(error => console.log(error))
Followed these steps https://docs.mlab.com/troubleshooting-connection-issues/
and i do have network access, i'm using database user credentials to connect (not my mLab account credentials) and my password just contains chars and numbers. That's the error i'm getting :
{ MongoNetworkError: failed to connect to server [***my_database***]
on first connect [MongoNetworkError: getaddrinfo ENOTFOUND ***my_database*** ***my_database***]
at Pool.<anonymous> (C:\Users\akain\Desktop\devconnector\node_modules\mongodb-core\lib\topologies\server.js:564:11)
at Pool.emit (events.js:182:13)
at Connection.<anonymous> (C:\Users\akain\Desktop\mongotest\node_modules\mongodb-core\lib\connection\pool.js:317:12)
at Object.onceWrapper (events.js:273:13)
at Connection.emit (events.js:182:13)
at Socket.<anonymous> (C:\Users\akain\Desktop\mongotest\node_modules\mongodb-core\lib\connection\connection.js:246:50)
at Object.onceWrapper (events.js:273:13)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
name: 'MongoNetworkError',
errorLabels: [ 'TransientTransactionError' ],
[Symbol(mongoErrorContextSymbol)]: {} }
Now the weird part : If i try to connect to mLab using mongo shell, not only everything works (from the shell), but i'm also able to connect without problem from my app. As soon as i close the shell and restart the app i get the error again.
I've also tried using mongoDb Node client instead of mongoose getting the same exact behaviour.

UnhandledPromiseRejectionWarning: error: password authentication failed for user " " after npm start

I am using node version 8 and when i do an npm start below errors are seen. I guess after routes are created below errors are seen. Here "techwedge3" is the username of my system. The application works correctly even with the below errors.
Even i am able to connect to my postgres db.
Any idea on how to resolve the issue?
[JobRoute::create] Creating route.
[InterviewRoute::create] Creating route.
[Creating AdminRoute::create] Creating route.
[TenantRoute::create] Creating route.
[CriteriaRoute::create] Creating route.
(node:12212) UnhandledPromiseRejectionWarning: error: password authentication failed for user "techwedge3"
at Connection.parseE (C:\Development\vilearnnew\vilearn_node\node_modules\pg-promise\node_modules\pg\lib\connection.js:546:11)
at Connection.parseMessage (C:\Development\vilearnnew\vilearn_node\node_modules\pg-promise\node_modules\pg\lib\connection.js:371:19)
at Socket.<anonymous> (C:\Development\vilearnnew\vilearn_node\node_modules\pg-promise\node_modules\pg\lib\connection.js:114:22)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)

google cloud cannot connect to mongodb cluster

I have a MongoDB Cluster in MongoDB Atlas and I use this MONGO_URI that they provided to connect to it. The format is something like this:
mongodb://<USERNAME>:<PASSWORD>#cluster0-shard-00-00-nnn.gcp.mongodb.net:27017,cluster0-shard-00-01-nnn.gcp.mongodb.net:27017,cluster0-shard-00-02-nnn.gcp.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true
When I run my node.js program locally, I can read and write the database. However, when I deploy to google cloud, I'm having connecting to it. This is what I see in Google Console:
Mongoose connection "error" event fired with:
{ MongoError: connection 5 to cluster0-shard-00-02-32tq4.mongodb.net:27017 closed
at Function.MongoError.create (/srv/node_modules/mongoose/node_modules/mongodb-core/lib/error.js:29:11)
at TLSSocket.<anonymous> (/srv/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:214:22)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:121:20)
at TLSSocket.emit (events.js:211:7)
at _handle.close (net.js:557:12)
at Socket.done (_tls_wrap.js:356:7)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at TCP._handle.close [as _onclose] (net.js:557:12)
I've tried to add allow-mongodb to firewall with protocols and ports as tcp:27017, direction ingress, IP ranges 0.0.0.0/0 and it's still not working. Can someone tell me what I'm missing here?
P.S I'm kinda suspecting that I have to add my mongodb cluster's IP to firewall as well though I'm not sure

unable to run node js continuously on dedicated windows server

I have a Dedicated windows server, I am running my node express code on the server, but when an exception occurred like
error: remaining connection slots are reserved for non-replication superuser connections
at Connection.parseE (C:\node\zykrrapi\prod\myapp\node_modules\pg\lib\connection.js:554:11)
at Connection.parseMessage (C:\node\zykrrapi\prod\myapp\node_modules\pg\lib\connection.js:381:17)
at TLSSocket.<anonymous> (C:\node\zykrrapi\prod\myapp\node_modules\pg\lib\connection.js:117:22)
at TLSSocket.emit (events.js:180:13)
at addChunk (_stream_readable.js:269:12)
at readableAddChunk (_stream_readable.js:256:11)
at TLSSocket.Readable.push (_stream_readable.js:213:10)
at TLSWrap.onread (net.js:578:20)
Emitted 'error' event at:
at Connection.<anonymous> (C:\node\zykrrapi\prod\myapp\node_modules\pg\lib\client.js:183:19)
at Connection.emit (events.js:180:13)
at TLSSocket.<anonymous> (C:\node\zykrrapi\prod\myapp\node_modules\pg\lib\connection.js:121:12)
at TLSSocket.emit (events.js:180:13)
[... lines matching original stack trace ...]
at TLSWrap.onread (net.js:578:20)
and another error like "too many connections to the user on database" error also occurs and stops the execution of the code. this makes a huge loss of the data for me.
I want to run the Node Js Code continuously and to start the execution again if it stopped unexpectedly.
I am running the code using command "npm start" in windows server...
I want this node code to run only on the windows dedicated server.

Resources