Giter Club home page Giter Club logo

Comments (39)

eaglevision20 avatar eaglevision20 commented on August 16, 2024 3

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.

from kue.

behrad avatar behrad commented on August 16, 2024 2

@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.

from kue.

davidwood avatar davidwood commented on August 16, 2024

I'm confused - are you using Kue or reds? I haven't used reds, but in looking at the package.json, it doesn't look like it uses Kue.

If we just focus on Kue and look at your example, you're requiring the node.js Redis client, but not actually overriding the Kue function that creates the client. Try the following to create a Kue instance (named jobs) with a connection to Redis on example.com:1234:

var redis = require('redis'),
    kue = require('kue');

kue.redis.createClient = function() {
    var client = redis.createClient(1234, "example.com");
    return client;
}

var jobs = kue.createQueue();

from kue.

esamattis avatar esamattis commented on August 16, 2024

I'm using Kue and Kue uses Reds under the hood.

As I stated, it doesn't help if you override the creator function in kue. Your code fails with the same error.

from kue.

davidwood avatar davidwood commented on August 16, 2024

What version of Kue are you using? I just ran the above code using Kue 0.2.0 without issue. Your code (and subsequent stack trace) wasn't overriding the Kue creator function - can you provide code that overrides the creator function and the stack trace?

from kue.

esamattis avatar esamattis commented on August 16, 2024

I'm using Kue master from Github.

Is there a Redis instance running on your localhost when you tested the code?

from kue.

esamattis avatar esamattis commented on August 16, 2024

I'll get this if I use the code you posted (just changed the server and port):

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)

from kue.

esamattis avatar esamattis commented on August 16, 2024

Also if add an another Redis instance to my localhost: Both Redis instances, remote and the local, will get connected when I run your code and I won't get the error. Obviously.

from kue.

davidwood avatar davidwood commented on August 16, 2024

Ok, I see what's happening now. I was looking at the 0.2.0 release, not master. I have a workaround - it's not pretty, but it works :)


var redis = require('redis'),
    reds = require('reds');

reds.createClient = function() {
  var client = redis.createClient(1234, "example.com");
  return client;
}

var kue = require('kue');
kue.redis.createClient = reds.createClient;
var jobs = kue.createQueue();    

from kue.

davidwood avatar davidwood commented on August 16, 2024

In order for this to work, you'll need to make sure reds is installed for your application (with npm install reds) and not installed under Kue (rm -R node_modules/kue/node_modules/reds)

from kue.

tj avatar tj commented on August 16, 2024

haha the joys of trying to share config like this blah. Yeah, we'll definitely need a reasonable solution for this in the next release. We dont have much choice other than to do kue.reds.createClient = kue.redis.createClient = fn etc, ugly but other than duplicating a ton of other logic in redis etc there's no easy way around it

from kue.

davidwood avatar davidwood commented on August 16, 2024

The thing that makes this tricky is that lib/queue/job.js and lib/http/routes/json.js create the reds search when required, so currently you need to override the reds Redis client creation function before Kue is required. This seems less than ideal, so I've created a branch (named lazy-create-reds) that makes this a bit easier by lazily creating the reds search with an overridden reds.createClient upon first access.

This change updates lib/queue/job.js and lib/http/routes/json.js.

from kue.

tj avatar tj commented on August 16, 2024

it's ideal as far as simplicity goes but yeah im fine with changing it for this

from kue.

tj avatar tj commented on August 16, 2024

@davidwood merged

I wish we could do it with less of a hack, but I can't think of anything off hand

from kue.

davidwood avatar davidwood commented on August 16, 2024

I'm with you - it works, but doesn't feel quite right

from kue.

larsemann avatar larsemann commented on August 16, 2024

hi,

the problem still exists, with version 0.3.2 :/

is there any fix now? i'm trying to use kue on different machines with one redis server :)

Update: switched to 0.3.1. - everything working fine...
thank you anyway! keep up the good work!

from kue.

ntresch avatar ntresch commented on August 16, 2024

I don't understand the assertion that Kue uses Reds under the hood when Reds was written to emulate Kue?

from kue.

tj avatar tj commented on August 16, 2024

@ntresch huh? reds is full-text search, nothing more

from kue.

ntresch avatar ntresch commented on August 16, 2024

@visionmedia "I'm using Kue and Kue uses Reds under the hood.", was said by @epeli. I don't believe that this is true, and I don;t understand the assertion, hence the question.

from kue.

tj avatar tj commented on August 16, 2024

it is true, Kue uses Reds for the search

from kue.

ntresch avatar ntresch commented on August 16, 2024

That makes more sense, with the qualification "for the search", and I see it now in the source. Thanks!

from kue.

loudin avatar loudin commented on August 16, 2024

This is still an issue for 0.4.0:

Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED

from kue.

judyhe avatar judyhe commented on August 16, 2024

Yep same with 0.5.0

from kue.

georgecoltart avatar georgecoltart commented on August 16, 2024

Pretty sure this is still happening, I can't stop the connection to localhost

from kue.

schonfeld avatar schonfeld commented on August 16, 2024

Still an issue with 0.7.5. Any chance of seeing a fix for this soon?

from kue.

behrad avatar behrad commented on August 16, 2024

@schonfeld would you provide the code for reproducing this?

from kue.

behrad avatar behrad commented on August 16, 2024

@schonfeld !!!!????

from kue.

iamkale avatar iamkale commented on August 16, 2024

I wandered over from Google, but this is happening to me in a standard node/redis/express app (bare bones..). Running on locahost connecting to a remote redis server (Elasticache on AWS) works fine, but from my EC2 server that doesn't have redis installed I can't seem to connect, since it tries to connect to localhost first even though I have config specific for the remote server running.

Sorry for off-topic, but this was one of few places I found this issue.

from kue.

behrad avatar behrad commented on August 16, 2024

would u please provide the stack trace of connection error?

from kue.

judyhe avatar judyhe commented on August 16, 2024

We forked awhile ago (0.5.0) and updated locally: https://github.com/floored/kue/commit/ec021e07b6ceea9f77bb9556ac2fb8035a880620. Never did a pull request because we assumed it would get fixed "for real".

from kue.

behrad avatar behrad commented on August 16, 2024

should be fixed in 0.8

from kue.

rvbsanjose avatar rvbsanjose commented on August 16, 2024

I'm trying to connect with Redis that is deployed on Heroku and I used the example @davidwood provided but I am still receiving the Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED. Any other ideas on how to fix this?

from kue.

rvbsanjose avatar rvbsanjose commented on August 16, 2024

@behrad I feel like a dummy. I was following along with the tutorials and never bothered to read the full doc on connecting. Once I read further down the doc page and followed the instructions, it worked just fine. Sorry for the inconvenience.

from kue.

petermekhaeil avatar petermekhaeil commented on August 16, 2024

What was the solution? I am getting this problem after a successful connect to a non-localhost url.

from kue.

59023g avatar 59023g commented on August 16, 2024

@eaglevision20 closest thing I could find: #875

If I have time I'll fork and look..

Maybe check the Pull Requests

from kue.

ganeshcse2991 avatar ganeshcse2991 commented on August 16, 2024

Still facing the same issue. Tried all the examples and pull requests too. Please help. Its still creating queue with local redis.

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

from kue.

fabulator avatar fabulator commented on August 16, 2024

@ganeshcse2991 as was said in comment earlier #54 (comment) Problem is requiring app from kue before creating a queue. Something like this: import kue, { app } from 'kue'; At least it was my issue and it is working fine for me now.

from kue.

shierro avatar shierro commented on August 16, 2024

@behrad thanks for the input about creating the queue before calling kue.app you are awesome!

queueService.initQueue(REDIS_HOST, REDIS_PORT);
app.use('/kue-api/', basicAuth, require('kue').app);

from kue.

sinisavukovic avatar sinisavukovic commented on August 16, 2024

@behrad @shierro. Thanks!

For those who are still looking for a quick answer:

import kue from "kue";
import express from "express";

kue.createQueue({
  prefix: 'q',
  redis: {
    port: <REDIS_PORT>,
    host: "<REDIS_HOST>"
  }
});

const app = express();
app.use("/kue-api/", kue.app);

from kue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.