Automattic / kue

Kue is a priority job queue backed by redis, built for node.js.
http://automattic.github.io/kue
MIT License
9.46k stars 867 forks source link

how to connect with dockerized redis container #1119

Closed pritisolanki closed 7 years ago

pritisolanki commented 7 years ago
kue.redis.createClient = function () {

    var redisUrl = url.parse(process.env.REDIS_URL);
    var client = redis.createClient(redisUrl.port, redisUrl.hostname);
    if (redisUrl.auth) {
        client.auth(redisUrl.auth.split(":")[1]);
    }
    return client;
};

var jobs = kue.createQueue();
console.log(jobs);

I am getting following error

Queue { name: 'kue', id: 'kue:2bddc6c83007:12', _otions: { prefix: 'q', redis: {} }, promoter: null, workers: [], shuttingDown: false, client: RedisClient { domain: null, _events: { newListener: [Function], error: [Function] }, _eventsCount: 2, _maxListeners: undefined, address: '127.0.0.1:6379', connection_options: { port: 6379, host: '127.0.0.1', family: 4 }, connection_id: 0, connected: false, ready: false, should_buffer: true, max_attempts: 0, command_queue: { [String: ''] _capacity: 16, _length: 0, _front: 0 }, offline_queue: { [String: '[object Object]'] _capacity: 16, _length: 1, _front: 0 }, pipeline_queue: { [String: ''] _capacity: 16, _length: 0, _front: 0 }, connect_timeout: 3600000, enable_offline_queue: true, retry_max_delay: null, retry_timer: null, rety_totaltime: 0, retry_delay: 200, retry_backoff: 1.7, attempts: 1, pub_sub_mode: 0, subscription_set: {}, monitoring: false, message_buffers: false, closing: false, server_info: {}, auth_pass: undefined, selected_db: undefined, old_state: null, fire_strings: true, pipeline: false, sub_commands_left: 0, times_connected: 0, buffers: false, options: { port: 6379, host: '127.0.0.1', socket_nodelay: true, socket_keepalive: true, return_buffers: false, detect_buffers: false }, reply: 'ON', reply_parser: JavascriptRedisParser { optionReturnBuffers: false, optionStringNumbers: false, returnError: [Function: returnError], returnFatalError: [Function: returnFatalError], returnReply: [Function: returnReply], name: 'javascript', offset: 0, buffer: null, bigStrSize: 0, bigOffset: 0, totalChunkSize: 0, bufferCache: [], arrayCache: [], arrayPos: [] }, stream: Socket { connecting: true, _hadError: false, _handle: [Object], _parent: null, _host: null, _readableState: [Object], readale: false, domain: null, _evnts: [Object], _eventsCount: 9, _maxListeners: undefined, _writableState: [Object], writable: true, allowHalfOpen: false,

    destroyed: false,
    _bytesDispatched: 0,
    _sockname: null,
    _pendingData: null,
    _pendingEncoding: '',
    server: null,
    _server: null },
 prefix: 'q',
 getKey: [Function],
 createFIFO: [Function],
 stripFIFO: [Function] } }

events.js:160 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:1018:11) at exports._exceptionWithHostPort (util.js:1041:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)

How can I resolve this ?