question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

kue (reds?) creates always a Redis connection to localhost when requiring

See original GitHub issue

Don’t know if this is kue or reds issue, but it certainly affects kue. Tested on kue master.

Consider following:

var redis = require("redis");                                                                                                                
var client = redis.createClient(1234, "example.com");                           

setTimeout(function() {                                                         
    require("kue");                                                   
}, 1000);                                                                       

client.on("connect", function() {                                               
  console.log("Connected!");                                                    
});                                                                             

It dies immediately after kue is required in the timeout:

Connected!

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: Redis connection to 127.0.0.1:6379 failed - ECONNREFUSED, Connection refused
    at Socket.<anonymous> (/home/epeli/tmp/kue/node_modules/reds/node_modules/redis/index.js:123:28)
    at Socket.emit (events.js:64:17)
    at Array.<anonymous> (net.js:830:27)
    at EventEmitter._tickCallback (node.js:126:26)

shell returned 1

Creates a second connection to localhost?

I think the reason is here:

A search is created on require https://github.com/LearnBoost/kue/blob/b2cd5d3393d12e4bdd1c2e654a3ef5eb45e5bf11/lib/queue/job.js#L27

which means new Search on Reds https://github.com/visionmedia/reds/blob/156c046803df6b96fa40e90be26b933f7d324d01/lib/reds.js#L68

which then again means a new Redis client which connects to localhost https://github.com/visionmedia/reds/blob/156c046803df6b96fa40e90be26b933f7d324d01/lib/reds.js#L236

This happens also if you override the createClient function in kue.

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:39 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
eaglevision20commented, Oct 10, 2016

I’ve been beating my head against this wall for a full day now. I’m running kue version 0.11 and node 4.5 but still cannot connect to a remote host. here is what my connection looks like:

const config = require(‘./config’); var Kue = require(‘kue’); var queue = Kue.createQueue({ redis: { port: 6379, //process.env.REDIS_PORT, host: ‘DOMAIN_HERE.com’ //process.env.REDIS_HOST, //auth: process.env.REDIS_PASS }, jobEvents: false, disableSearch: true, });

No matter what I try I get the same error back:

events.js:141 throw er; // Unhandled ‘error’ event ^

Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379 at Object.exports._errnoException (util.js:907:11) at exports._exceptionWithHostPort (util.js:930:20) at TCPConnectWrap.afterConnect as oncomplete

I have tried every example I can find and still nothing… 😦

Any help is greatly appreciated.

2reactions
behradcommented, Oct 2, 2014

@rvbsanjose make sure if you are calling createQueue(…) before accessing kue.app express application, and also try with disableSearch: true. Finally provide the code so that I can fix it, however I don’t believe it is a bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Connecting to redis using kue always creates a ...
I used a different way to setup the connection and it works so far this is what I've done: app.redisClient = redis.createClient(config.redisPort, config....
Read more >
Redis with Node.js (node_redis) | Redis Documentation Center
To use Redis with Node.js, you need to install a Node.js Redis client. The following sections explain ... The following code creates a...
Read more >
Step 4: Connect to the cluster's node - Amazon ElastiCache ...
Log in to an Amazon EC2 instance and connect to a node in the cache cluster. ... Choose the cluster you created in...
Read more >
Redis client connects to the redis remote server but can't read ...
I've to manage two servers 'Node_server' and a redis server ... var RedisStore = require('connect-redis')(session); var bodyParser ...
Read more >
Getting started with Redis
Running redis-cli followed by a command name and its arguments will send this command to the Redis instance running on localhost at port...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found