kue icon indicating copy to clipboard operation
kue copied to clipboard

[createClientFactory] Trying to connect to localhost when using createClientFactory

Open petermekhaeil opened this issue 8 years ago • 5 comments

Kue is trying to make a connect to localhost after I have successfully connected to a non-localhost redis server.

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:870:11)
    at exports._exceptionWithHostPort (util.js:893:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1063:14)

This happens after I successfully connect to my redis server (which does not sit on localhost).

My dependencies:

├── [email protected]
├── [email protected]
├── [email protected]

I am using node-redis has my redisClient:


    app.redisClient = redis.createClient(config.redis.port, config.redis.host);
    app.jobs = kue.createQueue({
        redis: {
            createClientFactory: function () {
                return app.redisClient;
            }
        },
        disableSearch: true
    });

Is Kue trying to make another connection for another feature that I am not across?

Cheers, Peter

petermekhaeil avatar May 24 '16 08:05 petermekhaeil

in createClientFactory You should return a configured client instance not the factory method app.redisClient

behrad avatar May 24 '16 11:05 behrad

Sorry, I missed that in the initial post.

app.redisClient = redis.createClient(config.redis.port, config.redis.host);

I know connection is successful because I logged it:

app.redisClient.on('connect', function () {
    console.info('successful connection to redis server');
});

But soon right after I get the error mentioned above

successful connection to redis server
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:870:11)
    at exports._exceptionWithHostPort (util.js:893:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1063:14)

petermekhaeil avatar May 24 '16 13:05 petermekhaeil

I solved it by using the default redis client from Kue

    app.jobs = kue.createQueue({
        prefix: config.redis.prefix,
        redis: {
            port: config.redis.port,
            host: config.redis.host
        }
    });

petermekhaeil avatar May 25 '16 04:05 petermekhaeil

Then I shall rename the topic if you don't mind

behrad avatar May 25 '16 15:05 behrad

Hello. I had the same issue with an app. We had attached a debugger and, when stepping through the functions, kue resolves the name just fine. However, when we let it run without stepping, it tries to connect to 127.0.0.1 instead.

We saw that, when we call createQueue during the step through, the Queue singleton already exists. Is that expected?

Does this function have some kind of callback?

retpolanne avatar Mar 25 '19 17:03 retpolanne