cuzmAZN
cuzmAZN

Reputation: 387

Redis in Nodejs on Cloud9 IDE: [Error: Auth error: undefined]

Here is my code:

var express = require("express"),
    app = express(),
    server = require("http").createServer(app),
    io = require("socket.io").listen(server),
    redis = require("redis"),
    env = {PORT: process.env.PORT || 8080, IP: process.env.IP || "localhost"};

client = redis.createClient(env.PORT , env.IP);
client.on("error", function(err) {
    console.log(err);
});

server.listen(env.PORT);
console.log("Server started @ " + env.IP + ":" + env.PORT);

After trying to run, I received the followings on the console:

Running Node Process
Your code is running at 'http://modified.address.c9.io'.
Important: use 'process.env.PORT' as the port and 'process.env.IP' as the host in your scripts!
info: socket.io started
Server started @ modified.ip.address.1:8080
[Error: Auth error: undefined]

I tried establishing the connection, and it connects to the IP and PORT perfectly. However, the error [Error: Auth error: undefined] appears and stops there. I Googled the error, the supports from the IDE I used..., and surprisingly, there are only 7 links to my problems. So I think it may be a hole in my knowledge or it is not really a problem yet a thing I don't know to work it out. All I could pull out from those Google results were (I was not sure) I need to use client.auth(pass) right after creating it. But where should I find the password? When I installed it npm install redis I didn't configure anything and wasn't told to set password whatsoever. So I reach the impasse.

I use Cloud9 IDE (c9.io), and the modules used as shown in the code above.

----With best regards, ----Tim.

Upvotes: 2

Views: 1034

Answers (2)

cuzmAZN
cuzmAZN

Reputation: 387

I've found out what was wrong.

I did install Redis, but that is a Redis library that acts like a bridge between Redis driver and NodeJS. On Cloud9, I have to manually install Redis, too.

So it would take 2 commands to actually install Redis:

Install the Redis Driver on Cloud9

nada-nix install redis

Install Redis library for NodeJS

npm install redis

Thanks for anyone who was trying to help me.

Upvotes: 1

sachin
sachin

Reputation: 14375

You can run the redis-server using your own config file.You can create your own config like below.

 //port and ip of ur redis server
  port 6371
  bind 127.0.0.1
  //password for this server
  requirepass ucanmentionurpwd
  //storing snapshots of the data 
  save 60 1
  dbfilename dump.rdb
  dir /tmp/db

  //starting redis server
   redis-server //ur config file location

See this link for redis configuration https://raw.github.com/antirez/redis/2.6/redis.conf

If you mention requirepass with your password means only you need to do

         client.auth('urPwd');

Otherwise no need to call the client.auth method.

Upvotes: 0

Related Questions