Redis-node : Ready check failed: NOAUTH Authentication required - node.js

I am using the redis package on npm after installing the redis from the digital ocean guide I secured it using one of their post. I set the requirepass to a password and then logged into my redis-cli and authenticated myself successfully. But I am unable to do the same from my Node.js application.
This is my config in Node
client = redis.createClient({
no_ready_check: true,
host : 'ip address',
port : port
});
client.auth('secretPassword', function(err, doc){
if(err)
throw err;
else if(doc === "OK"){
console.log("Authenticated");
}
});
client.on('error' , function (err) {
console.log("Error");
});
After I run it. I get this error
events.js:160
throw er; // Unhandled 'error' event
^
ReplyError: Ready check failed: NOAUTH Authentication required.
at parseError (/home/ubuntu/demo/vehico-workers/node_modules/redis-parser/lib/parser.js:181:12)
at parseType (/home/ubuntu/demo/vehico-workers/node_modules/redis-parser/lib/parser.js:291:14)
From my best guess, the node-redis driver doesn't implement it properly as I am able to authenticate from cli but not from Node application. Anybody who is running a secure redis.conf on AWS EC2 successfully?

I have the same probleme, and didnt find any solution on the Internet.
I change the directive pass to password in setting.js
redis: { host: "192.168.x.xx", password: '******', port: 6379 },
storageModule: require("node-red-contrib-redis-storage"),
And it work well.

Related

MongoDB not authorized error on Ubuntu 16.04

I am installing a server on Digitalocean and have a MongoDB issue. I installed Mongo on the server and allowed remote access.
I created two users. One is super-user for me and the other is a regular user for the website users. I am able to connect to the mongo through Robomongo 3T (a mongo client) remotely for both users.
However, when I use the application from a browser, a simple login request gives an authentication error. Here is the error:
MongoError: not authorized on DATABASE_NAME to execute command { find: "users", filter: { email: "YYY", password: "XXX" }, limit: 1, singleBatch: true, batchSize: 1 }
Here is the realted server-side code:
Connecting the database at server.js:
MongoClient.connect(config.mongo_url, (err, client) => {
if(err) throw err
console.log('db connected')
app.locals.db = client
// start the server
app.listen(process.env.PORT || 3000, ()=>console.log('listening on port 3000!'))
});
Trying to connect to the local mongo on the server:
database.collection(config.mongo_col_user)
.findOne({
email: username,
password: hash
}, (err, user)=>{
if(err) return done(err)
if(!user) return done(null, false, {msg: 'not found'})
if(user.password)
return done(null, user)
})
I use pm2 on the server side and I use ecosystem.config.js which has the below code:
module.exports = {
apps : [
{
name: "NAME",
script: "SCRIPT_NAME",
watch: true,
env: {
"mongo_url": 'mongodb://USER_NAME:PASSWORD#localhost:27017?authMechanism=SCRAM-SHA-1&authSource=DATABASE_NAME',
"mongo_db_name": 'DATABASE_NAME',
"mongo_col_query": "COLLECTION_NAME",
}
}
]
}
Could you help with the problem please?
I have figured it out.
When I did make changes to pm2 environment file ecosystem.config.js, I did always restart pm2 with pm2 restart all. However, when you change the file, you should tell pm2 that you changed it by pm2 reload ecosystem.config.js --update-env.
Additionally, the correct syntax is no
mongodb://USER_NAME:PASSWORD#localhost:27017?authMechanism=SCRAM-SHA-1&authSource=DATABASE_NAME'
but
mongodb://USER_NAME:PASSWORD#localhost:27017/DATABASE_NAME'

How to connect to a implicit FTPS server with nodeJS?

For a project I have to connect to a FTPS server over a implicit connection.
I tried with node-ftp, because it seems that this is the only library, that supports the implicit connection.
I connect using the following code:
var ftpC = new FTPClient();
ftpC.on('ready', function () {
console.log('Connection successful!');
});
ftpC.on('error', function (err) {
console.log(err);
});
console.log('Try to connect to FTP Server...');
ftpC.connect({
host: HOST_TO_CONNECT,
port: 990,
secure: 'implicit',
user: '***',
password: '***',
secureOptions: {
rejectUnauthorized: false
// secureProtocol: 'SSLv23_method',
// ciphers: 'ECDHE-RSA-AES128-GCM-SHA256'
}
})
This code gives me everytime a timeout error. If I raise the timeout, the error comes later.
I tried in secureOptions to add the params rejectUnauthorized, secureProtocol and ciphers, as you can see. None of them is working. Everytime I get this timeout error.
In FileZilla I have no problem to connect. Everything is working fine.
Do someone have a solution for this behavior?
Or is there another plugin for nodejs to connect to a implicit FTPS server?
This appears to be a bug in node-ftp. I've created a PR for it and will update this as soon as it's been fixed.

Error: All configured authentication methods failed levels: 'client-authentication'

I am using node.js ssh2 module.I have installed ssh2 module by executing the command 'npm install ssh2'.However, when I use ssh2 to connect to a remote server, it always output the error:
[Error: All configured authentication methods failed] levels: 'client-authentication'
This is my code
var Client = require('ssh2').Client
var conn = new Client();
var option = {
host: '10.171.65.154',
port: 22,
username: 'root',
password: '123456'
};
conn.on('ready', function(){
console.log('Client :: ready');
conn.sftp(function(err, sftp){
if(err) throw err;
sftp.readdir('home', function(err, list){
if(err) throw err;
console.dir(list);
conn.end();
});
});
}).on('error', function(err){
console.log(err);
}).connect(option);
However, I can not connect successfully.I am sure the username and password are correct and I can connect successfully by SecureCRT.
it always output the error:
[Error: All configured authentication methods failed] levels: 'client-authentication'
Probably, you have to handle keyboard-interactive authentication (which is not the same as password). Try something like this:
connection.on('ready', function(){
console.log("Connected!");
}).on('error', function(err){
console.error(err);
}).on('keyboard-interactive', function (name, descr, lang, prompts, finish) {
// For illustration purposes only! It's not safe to do this!
// You can read it from process.stdin or whatever else...
var password = "your_password_here";
return finish([password]);
// And remember, server may trigger this event multiple times
// and for different purposes (not only auth)
}).connect({
host: "your.host.or.ip",
port: 22,
username: "your_login",
tryKeyboard: true
});

Node.js MongoError: auth failed

I found out my website wasn't working anymore because i can't auth to my mongolab DB.
here is my code (it used to work for months):
var mongoose = require('mongoose');
mongoose.connect('mongodb://USER:PASSWORD#ds053419.mongolab.com:53419/jobinfest',
function(err) {
console.log(err);
if (err) { throw err; }
}
);
I have this error:
{ [MongoError: auth failed] name: 'MongoError', ok: 0, errmsg: 'auth failed', code: 18 }
But i can access the db via mongolab and :
mongo ds053419.mongolab.com:53419/jobinfest -u USER -p PASSWORD
I tried to create new users, even a new db. This way of connection seems to not work anymore
In your code be sure you are replacing USER:PASSWORD with your actual username and password.
mongodb://USER:PASSWORD#ds053419.mongolab.com:53419/jobinfest

Node.js Error : connect ECONN Refused

I am new to Node.js and am unable to resolve this error:
Error: connect ECONNREFUSED
at errnoException (net.js:901:11)
at Object.afterConnect (as oncomplete) (net.js:892)
The code I was trying out follows :
var async = require('async'),
request = require('request');
function done(err,results) {
if (err) {
throw err;
}
console.log('Done ! results: %j',results);
}
var collection = [1,2,3,4];
function iterator(value,callback) {
request.post({
url: 'http://localhost:8080',
body: JSON.stringify(value)
}, function (err,res,body){
if (err) {
callback(err,body && JSON.parse(body));
}
});
}
async.map(collection,iterator,done);
ECONNREFUSED – Connection refused by server error
A port is being blocked can be the root cause of this issue, check if your connection is being blocked or even the changed default port can also cause this issue. Identify which app/service you are connecting to and its port is being blocked or changed.
And in your case check whether the application is hosted on port: 8080 or not.
But, this most likely occurs with FileZilla.

Resources